Skip to content

Commit

Permalink
Added unit test for #704.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitelynx authored and tgriesser committed Feb 25, 2015
1 parent 0a71835 commit b8c401d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/unit/query/builder.js
Expand Up @@ -2241,6 +2241,28 @@ module.exports = function(qb, clientName, aliasName) {
});
});

it('correctly orders parameters when selecting from subqueries, #704', function() {
var subquery = qb().select(raw('? as f', ['inner raw select'])).as('g');
testsql(qb()
.select(raw('?', ['outer raw select']), 'g.f')
.from(subquery)
.where('g.secret', 123),
{
mysql: {
sql: 'select ?, `g`.`f` from (select ? as f) as `g` where `g`.`secret` = ?',
bindings: ['outer raw select', 'inner raw select', 123]
},
oracle: {
sql: 'select ?, "g"."f" from (select ? as f) "g" where "g"."secret" = ?',
bindings: ['outer raw select', 'inner raw select', 123]
},
default: {
sql: 'select ?, "g"."f" from (select ? as f) as "g" where "g"."secret" = ?',
bindings: ['outer raw select', 'inner raw select', 123]
}
});
});

});

};

0 comments on commit b8c401d

Please sign in to comment.