123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- var Test = require('../../support/test-runner');
- describe('Query Generation ::', function() {
- describe('UNION ALL statements', function() {
- it('should generate a UNION ALL query', function(done) {
- Test({
- query: {
- select: ['*'],
- from: 'users',
- where: {
- and: [
- {
- firstName: 'Bob'
- }
- ]
- },
- unionAll: [
- {
- select: ['*'],
- from: 'users',
- where: {
- and: [
- {
- lastName: 'Smith'
- }
- ]
- }
- },
- {
- select: ['*'],
- from: 'users',
- where: {
- and: [
- {
- middleName: 'Allen'
- }
- ]
- }
- }
- ]
- },
- outcomes: [
- {
- dialect: 'postgresql',
- sql: 'select * from "users" where "firstName" = $1 union all (select * from "users" where "lastName" = $2) union all (select * from "users" where "middleName" = $3)',
- bindings: ['Bob', 'Smith', 'Allen']
- },
- {
- dialect: 'mysql',
- sql: 'select * from `users` where `firstName` = ? union all (select * from `users` where `lastName` = ?) union all (select * from `users` where `middleName` = ?)',
- bindings: ['Bob', 'Smith', 'Allen']
- },
- {
- dialect: 'sqlite3',
- sql: 'select * from "users" where "firstName" = ? union all (select * from "users" where "lastName" = ?) union all (select * from "users" where "middleName" = ?)',
- bindings: ['Bob', 'Smith', 'Allen']
- },
- {
- dialect: 'oracle',
- sql: 'select * from "users" where "firstName" = :1 union all (select * from "users" where "lastName" = :2) union all (select * from "users" where "middleName" = :3)',
- bindings: ['Bob', 'Smith', 'Allen']
- },
- {
- dialect: 'mariadb',
- sql: 'select * from `users` where `firstName` = ? union all (select * from `users` where `lastName` = ?) union all (select * from `users` where `middleName` = ?)',
- bindings: ['Bob', 'Smith', 'Allen']
- }
- ]
- }, done);
- });
- });
- });
|