Skip to content

Commit eb7fd2c

Browse files
committed
fix multi-field object in where clause bug
When a multi-field object is passed to a where clause, all fields except the first one were being ignored. This commit fixes the bug.
1 parent 0163fdc commit eb7fd2c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/node/where.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var normalizeNode = function(table, node) {
1717
if (!result)
1818
result = query;
1919
else
20-
result.and(query);
20+
result = result.and(query);
2121
}
2222
}
2323
return result;

test/dialects/table-tests.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ Harness.test({
166166
params: ['brian']
167167
});
168168

169+
Harness.test({
170+
query : user.select('name').from('user').where({name: 'brian', id: 1}),
171+
pg : 'SELECT name FROM user WHERE (("user"."name" = $1) AND ("user"."id" = $2))',
172+
sqlite: 'SELECT name FROM user WHERE (("user"."name" = $1) AND ("user"."id" = $2))',
173+
mysql : 'SELECT name FROM user WHERE ((`user`.`name` = ?) AND (`user`.`id` = ?))',
174+
params: ['brian', 1]
175+
});
176+
169177
Harness.test({
170178
query : user.select(user.name.as('quote"quote"tick`tick`')),
171179
pg : 'SELECT "user"."name" AS "quote""quote""tick`tick`" FROM "user"',

0 commit comments

Comments
 (0)