2013-09-08 15:57:32 -04:00
|
|
|
var _ = require('underscore');
|
|
|
|
var Knex = require('../../knex');
|
2013-09-11 23:36:55 -04:00
|
|
|
var nodefn = require('when/node/function');
|
2013-09-08 15:57:32 -04:00
|
|
|
|
|
|
|
var config = require(process.env.KNEX_TEST || './config');
|
|
|
|
|
|
|
|
var pool = {
|
2013-09-13 16:50:51 -04:00
|
|
|
afterCreate: function(connection, callback) {
|
2013-09-08 15:57:32 -04:00
|
|
|
expect(connection).to.have.property('__cid');
|
2013-09-13 16:50:51 -04:00
|
|
|
callback(null, connection);
|
2013-09-08 15:57:32 -04:00
|
|
|
},
|
2013-09-11 23:36:55 -04:00
|
|
|
beforeDestroy: function(connection) {
|
2013-09-08 15:57:32 -04:00
|
|
|
expect(connection).to.have.property('__cid');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var MySQL = Knex.initialize({
|
|
|
|
client: 'mysql',
|
|
|
|
connection: config.mysql,
|
|
|
|
pool: _.extend({}, pool, {
|
2013-09-13 16:50:51 -04:00
|
|
|
afterCreate: function(connection, callback) {
|
|
|
|
nodefn.call(connection.query.bind(connection), "SET sql_mode='TRADITIONAL';", []).then(function() {
|
|
|
|
callback(null, connection);
|
|
|
|
});
|
2013-09-08 15:57:32 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
var PostgreSQL = Knex.initialize({
|
|
|
|
client: 'postgres',
|
|
|
|
connection: config.postgres,
|
|
|
|
pool: pool
|
|
|
|
});
|
|
|
|
|
2013-09-11 23:36:55 -04:00
|
|
|
var SQLite3 = Knex.initialize({
|
|
|
|
client: 'sqlite3',
|
|
|
|
connection: config.sqlite3,
|
|
|
|
pool: pool
|
|
|
|
});
|
|
|
|
|
|
|
|
_.each([MySQL, PostgreSQL, SQLite3], function(knex) {
|
2013-09-08 15:57:32 -04:00
|
|
|
|
|
|
|
describe('Dialect: ' + knex.client.dialect, function() {
|
|
|
|
|
2013-09-12 13:30:47 -04:00
|
|
|
this.dialect = knex.client.dialect;
|
|
|
|
|
2013-09-08 15:57:32 -04:00
|
|
|
require('./builder/schema')(knex);
|
|
|
|
require('./builder/inserts')(knex);
|
|
|
|
require('./builder/selects')(knex);
|
2013-09-12 01:00:44 -04:00
|
|
|
require('./builder/unions')(knex);
|
|
|
|
require('./builder/joins')(knex);
|
|
|
|
require('./builder/aggregate')(knex);
|
2013-09-08 15:57:32 -04:00
|
|
|
require('./builder/updates')(knex);
|
2013-09-11 23:36:55 -04:00
|
|
|
require('./builder/transaction')(knex);
|
2013-09-08 15:57:32 -04:00
|
|
|
require('./builder/deletes')(knex);
|
2013-09-12 01:00:44 -04:00
|
|
|
require('./builder/additional')(knex);
|
2013-09-08 15:57:32 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-09-11 23:36:55 -04:00
|
|
|
});
|