Skip to content

Commit

Permalink
Fixes bug on EXISTS query part (dresende/node-orm2#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
dresende committed Apr 17, 2013
1 parent b1b85a5 commit 59fc476
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions lib/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,11 @@ function SelectQuery(Dialect) {
return this;
},
whereExists: function (table, table_link, link, conditions) {
var where = [{
sql.where.push({
t: (sql.from.length ? sql.from[sql.from.length - 1].a : null),
w: conditions,
e: { t: table, tl: get_table_alias(table_link), l: link }
}];
if (sql.where.length) {
sql.where[sql.where.length - 1] = sql.where[sql.where.length - 1].concat(where);
} else {
sql.where.push(where);
}
});
return this;
},
groupBy: function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/Where.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function buildOrGroup(Dialect, where) {
"EXISTS (" +
"SELECT * FROM " + Dialect.escapeId(where.e.t) + " " +
"WHERE " + Dialect.escapeId(where.e.l[0]) + " = " + Dialect.escapeId(where.e.tl, where.e.l[1]) + " " +
"AND " + buildOrGroup(Dialect, [{ t: null, w: where.w }]) +
"AND " + buildOrGroup(Dialect, { t: null, w: where.w }) +
")"
];
}
Expand Down

0 comments on commit 59fc476

Please sign in to comment.