knex/test/knexfile.js

191 lines
4.0 KiB
JavaScript
Raw Permalink Normal View History

'use strict';
Fix #2545, bring redshift wrapIdentifier custom hook up to date with postgres (#2551) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments * Sublime Text gitignore * Redshift does not support adding more than one column in alter table * Fix integration tests for redshift * Linter * Combine dialect test skip if clause
2018-04-04 18:43:39 -04:00
/* eslint no-var: 0 */
2019-06-08 02:34:41 +02:00
const assert = require('assert');
const { promisify } = require('util');
2019-06-08 02:34:41 +02:00
const testConfig =
(process.env.KNEX_TEST && require(process.env.KNEX_TEST)) || {};
2019-06-08 02:34:41 +02:00
const _ = require('lodash');
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
// excluding redshift, oracle, and mssql dialects from default integrations test
2019-06-08 02:34:41 +02:00
const testIntegrationDialects = (
process.env.DB ||
'sqlite3 postgres pgnative mysql mysql2 mssql oracledb cockroachdb'
).match(/\w+/g);
2014-08-11 12:25:39 +02:00
console.log(`ENV DB: ${process.env.DB}`);
2019-06-08 02:34:41 +02:00
const pool = {
2020-04-19 00:40:23 +02:00
afterCreate: function (connection, callback) {
assert.ok(typeof connection.__knexUid !== 'undefined');
callback(null, connection);
},
};
2019-06-08 02:34:41 +02:00
const poolSqlite = {
min: 0,
max: 1,
acquireTimeoutMillis: 1000,
2020-04-19 00:40:23 +02:00
afterCreate: function (connection, callback) {
assert.ok(typeof connection.__knexUid !== 'undefined');
connection.run('PRAGMA foreign_keys = ON', callback);
},
};
2019-06-08 02:34:41 +02:00
const mysqlPool = _.extend({}, pool, {
2020-04-19 00:40:23 +02:00
afterCreate: function (connection, callback) {
promisify(connection.query)
.call(connection, "SET sql_mode='TRADITIONAL';", [])
2020-04-19 00:40:23 +02:00
.then(function () {
callback(null, connection);
});
},
2015-04-30 21:19:33 -04:00
});
2019-06-08 02:34:41 +02:00
const migrations = {
directory: 'test/integration/migrate/migration',
};
2019-06-08 02:34:41 +02:00
const seeds = {
directory: 'test/integration/seed/seeds',
2014-07-21 18:38:40 -04:00
};
2019-06-08 02:34:41 +02:00
const testConfigs = {
mysql: {
client: 'mysql',
connection: testConfig.mysql || {
port: 23306,
database: 'knex_test',
host: 'localhost',
user: 'testuser',
password: 'testpassword',
charset: 'utf8',
},
2015-04-30 21:19:33 -04:00
pool: mysqlPool,
migrations,
seeds,
},
mysql2: {
client: 'mysql2',
connection: testConfig.mysql || {
port: 23306,
database: 'knex_test',
host: 'localhost',
user: 'testuser',
password: 'testpassword',
charset: 'utf8',
},
2015-04-30 21:19:33 -04:00
pool: mysqlPool,
migrations,
seeds,
},
oracledb: {
client: 'oracledb',
connection: testConfig.oracledb || {
user: 'system',
password: 'Oracle18',
connectString: 'localhost:21521/XE',
// https://github.com/oracle/node-oracledb/issues/525
stmtCacheSize: 0,
},
pool,
migrations,
},
postgres: {
client: 'postgres',
connection: testConfig.postgres || {
adapter: 'postgresql',
port: 25432,
host: 'localhost',
database: 'knex_test',
user: 'testuser',
password: 'knextest',
},
pool,
migrations,
seeds,
},
2021-09-06 09:04:23 -04:00
cockroachdb: {
client: 'cockroachdb',
connection: testConfig.cockroachdb || {
adapter: 'cockroachdb',
port: 26257,
host: 'localhost',
database: 'test',
user: 'root',
password: undefined,
},
pool,
migrations,
seeds,
},
2021-09-06 09:04:23 -04:00
pgnative: {
client: 'pgnative',
connection: testConfig.pgnative || {
adapter: 'postgresql',
port: 25433,
host: 'localhost',
database: 'knex_test',
user: 'testuser',
password: 'knextest',
},
pool,
migrations,
seeds,
},
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
redshift: {
client: 'redshift',
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
connection: testConfig.redshift || {
adapter: 'postgresql',
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
database: 'knex_test',
user: process.env.REDSHIFT_USER || 'postgres',
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
password: process.env.REDSHIFT_PASSWORD || '',
port: '5439',
host: process.env.REDSHIFT_HOST || '127.0.0.1',
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
},
pool,
migrations,
seeds,
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
},
sqlite3: {
client: 'sqlite3',
2015-12-08 11:37:31 -06:00
connection: testConfig.sqlite3 || {
filename: __dirname + '/test.sqlite3',
},
pool: poolSqlite,
migrations,
seeds,
2015-12-08 11:37:31 -06:00
},
2015-12-14 11:10:46 -06:00
mssql: {
client: 'mssql',
2015-12-14 11:10:46 -06:00
connection: testConfig.mssql || {
user: 'sa',
password: 'S0meVeryHardPassword',
server: 'localhost',
port: 21433,
database: 'knex_test',
2015-12-14 11:10:46 -06:00
},
pool: pool,
migrations,
seeds,
},
2014-08-11 12:25:39 +02:00
};
2014-08-11 12:25:39 +02:00
// export only copy the specified dialects
module.exports = _.reduce(
testIntegrationDialects,
2020-04-19 00:40:23 +02:00
function (res, dialectName) {
res[dialectName] = testConfigs[dialectName];
return res;
},
{}
);