From 59fc476580c2e9b687e47ab7bf3a1ec137c35652 Mon Sep 17 00:00:00 2001 From: Diogo Resende Date: Thu, 18 Apr 2013 00:15:48 +0100 Subject: [PATCH] Fixes bug on EXISTS query part (dresende/node-orm2#94) --- lib/Select.js | 9 ++------- lib/Where.js | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/Select.js b/lib/Select.js index 6f05226..1f39a27 100644 --- a/lib/Select.js +++ b/lib/Select.js @@ -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 () { diff --git a/lib/Where.js b/lib/Where.js index 5070221..8e1ccbf 100644 --- a/lib/Where.js +++ b/lib/Where.js @@ -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 }) + ")" ]; }