From 710cb0779f01e68d09f7b5b31abaa010172f7097 Mon Sep 17 00:00:00 2001 From: Tetsuo Seto Date: Fri, 12 May 2017 17:07:35 -0700 Subject: [PATCH] Avoid duplicate column restriction in where --- lib/sql.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/sql.js b/lib/sql.js index cea7bea..4845242 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -1159,7 +1159,12 @@ SQLConnector.prototype._buildWhere = function(model, where) { } } } - whereStmts.push(stmt); + var columnRestricted = false; + whereStmts.forEach(function(stmt) { + if (columnRestricted) return; + columnRestricted = stmt.sql.indexOf(columnName) >= 0; + }); + if (!columnRestricted) whereStmts.push(stmt); } var params = []; var sqls = [];