123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- var Test = require('../../support/test-runner');
- describe('Query Generation ::', function() {
- describe('WHERE IN statements', function() {
- it('should generate a query', function(done) {
- Test({
- query: {
- select: ['name'],
- from: 'users',
- where: {
- and: [
- {
- id: {
- in: [1, 2, 3]
- }
- }
- ]
- }
- },
- outcomes: [
- {
- dialect: 'postgresql',
- sql: 'select "name" from "users" where "id" in ($1, $2, $3)',
- bindings: ['1', '2', '3']
- },
- {
- dialect: 'mysql',
- sql: 'select `name` from `users` where `id` in (?, ?, ?)',
- bindings: ['1', '2', '3']
- },
- {
- dialect: 'sqlite3',
- sql: 'select "name" from "users" where "id" in (?, ?, ?)',
- bindings: ['1', '2', '3']
- },
- {
- dialect: 'oracle',
- sql: 'select "name" from "users" where "id" in (:1, :2, :3)',
- bindings: ['1', '2', '3']
- },
- {
- dialect: 'mariadb',
- sql: 'select `name` from `users` where `id` in (?, ?, ?)',
- bindings: ['1', '2', '3']
- }
- ]
- }, done);
- });
- it('should generate a query when inside an OR statement', function(done) {
- Test({
- query: {
- select: ['name'],
- from: 'users',
- where: {
- or: [
- {
- id: {
- in: [1, 2, 3]
- }
- },
- {
- id: {
- in: [4, 5, 6]
- }
- }
- ]
- }
- },
- outcomes: [
- {
- dialect: 'postgresql',
- sql: 'select "name" from "users" where "id" in ($1, $2, $3) or "id" in ($4, $5, $6)',
- bindings: ['1', '2', '3', '4', '5', '6']
- },
- {
- dialect: 'mysql',
- sql: 'select `name` from `users` where `id` in (?, ?, ?) or `id` in (?, ?, ?)',
- bindings: ['1', '2', '3', '4', '5', '6']
- },
- {
- dialect: 'sqlite3',
- sql: 'select "name" from "users" where "id" in (?, ?, ?) or "id" in (?, ?, ?)',
- bindings: ['1', '2', '3', '4', '5', '6']
- },
- {
- dialect: 'oracle',
- sql: 'select "name" from "users" where "id" in (:1, :2, :3) or "id" in (:4, :5, :6)',
- bindings: ['1', '2', '3', '4', '5', '6']
- },
- {
- dialect: 'mariadb',
- sql: 'select `name` from `users` where `id` in (?, ?, ?) or `id` in (?, ?, ?)',
- bindings: ['1', '2', '3', '4', '5', '6']
- }
- ]
- }, done);
- });
- });
- });
|