mirror of
https://github.com/knex/knex.git
synced 2025-07-31 21:02:11 +00:00

* GH-2915 Oracledb tests are failing - fixes oracledb failing tests * Fixes oracledb increment() and decrement() empty query - Error: The query is empty * Add ToDo for fixing Oracle bug
116 lines
2.9 KiB
JavaScript
116 lines
2.9 KiB
JavaScript
/*global describe, it*/
|
|
|
|
'use strict';
|
|
|
|
module.exports = function(knex) {
|
|
describe('unions', function() {
|
|
it('handles unions with a callback', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union(function() {
|
|
this.select('*')
|
|
.from('accounts')
|
|
.where('id', 2);
|
|
});
|
|
});
|
|
|
|
it('handles unions with an array of callbacks', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union([
|
|
function() {
|
|
this.select('*')
|
|
.from('accounts')
|
|
.where('id', 2);
|
|
},
|
|
function() {
|
|
this.select('*')
|
|
.from('accounts')
|
|
.where('id', 3);
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('handles unions with a list of callbacks', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union(
|
|
function() {
|
|
this.select('*')
|
|
.from('accounts')
|
|
.where('id', 2);
|
|
},
|
|
function() {
|
|
this.select('*')
|
|
.from('accounts')
|
|
.where('id', 3);
|
|
}
|
|
);
|
|
});
|
|
|
|
it('handles unions with an array of builders', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union([
|
|
knex
|
|
.select('*')
|
|
.from('accounts')
|
|
.where('id', 2),
|
|
knex
|
|
.select('*')
|
|
.from('accounts')
|
|
.where('id', 3),
|
|
]);
|
|
});
|
|
|
|
it('handles unions with a list of builders', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union(
|
|
knex
|
|
.select('*')
|
|
.from('accounts')
|
|
.where('id', 2),
|
|
knex
|
|
.select('*')
|
|
.from('accounts')
|
|
.where('id', 3)
|
|
);
|
|
});
|
|
|
|
it('handles unions with a raw query', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union(
|
|
knex.raw('select * from ?? where ?? = ?', ['accounts', 'id', 2])
|
|
);
|
|
});
|
|
|
|
it('handles unions with an array raw queries', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union([
|
|
knex.raw('select * from ?? where ?? = ?', ['accounts', 'id', 2]),
|
|
knex.raw('select * from ?? where ?? = ?', ['accounts', 'id', 3]),
|
|
]);
|
|
});
|
|
|
|
it('handles unions with a list of raw queries', function() {
|
|
return knex('accounts')
|
|
.select('*')
|
|
.where('id', '=', 1)
|
|
.union(
|
|
knex.raw('select * from ?? where ?? = ?', ['accounts', 'id', 2]),
|
|
knex.raw('select * from ?? where ?? = ?', ['accounts', 'id', 3])
|
|
);
|
|
});
|
|
});
|
|
};
|