2016-09-13 18:12:23 -04:00
/*eslint no-var:0, max-len:0 */
2014-09-01 17:18:45 +02:00
'use strict' ;
2020-03-08 19:48:23 -04:00
const { expect } = require ( 'chai' ) ;
2018-11-19 12:55:50 +01:00
const Knex = require ( '../../../knex' ) ;
const _ = require ( 'lodash' ) ;
2020-12-28 16:55:08 +02:00
const delay = require ( '../../../lib/execution/internal/delay' ) ;
2020-12-27 15:19:47 +02:00
const {
isPostgreSQL ,
isOracle ,
isRedshift ,
isSQLite ,
isMysql ,
2021-03-08 07:16:07 -05:00
isMssql ,
isPgBased ,
2021-09-06 09:04:23 -04:00
isPgNative ,
2020-12-27 15:19:47 +02:00
} = require ( '../../util/db-helpers' ) ;
2021-03-08 07:16:07 -05:00
const { DRIVER _NAMES : drivers } = require ( '../../util/constants' ) ;
2013-09-12 01:00:44 -04:00
2020-04-19 00:40:23 +02:00
module . exports = function ( knex ) {
describe ( 'Additional' , function ( ) {
2018-07-09 08:10:34 -04:00
describe ( 'Custom response processing' , ( ) => {
2017-10-12 18:16:15 +03:00
before ( 'setup custom response handler' , ( ) => {
2018-02-01 23:41:01 +01:00
knex . client . config . postProcessResponse = ( response , queryContext ) => {
2018-07-09 08:10:34 -04:00
response . callCount = response . callCount ? response . callCount + 1 : 1 ;
2018-02-01 23:41:01 +01:00
response . queryContext = queryContext ;
2017-10-12 18:16:15 +03:00
return response ;
} ;
} ) ;
after ( 'restore client configuration' , ( ) => {
knex . client . config . postProcessResponse = null ;
} ) ;
it ( 'should process normal response' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex ( 'accounts' )
. limit ( 1 )
. then ( ( res ) => {
expect ( res . callCount ) . to . equal ( 1 ) ;
} ) ;
2017-10-12 18:16:15 +03:00
} ) ;
2018-02-01 23:41:01 +01:00
it ( 'should pass query context to the custom handler' , ( ) => {
return knex ( 'accounts' )
. queryContext ( 'the context' )
. limit ( 1 )
2018-07-09 08:10:34 -04:00
. then ( ( res ) => {
2018-02-01 23:41:01 +01:00
expect ( res . queryContext ) . to . equal ( 'the context' ) ;
} ) ;
} ) ;
2017-10-12 18:16:15 +03:00
it ( 'should process raw response' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex . raw ( 'select * from ??' , [ 'accounts' ] ) . then ( ( res ) => {
2018-02-01 23:41:01 +01:00
expect ( res . callCount ) . to . equal ( 1 ) ;
2017-10-12 18:16:15 +03:00
} ) ;
} ) ;
2018-02-01 23:41:01 +01:00
it ( 'should pass query context for raw responses' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex
. raw ( 'select * from ??' , [ 'accounts' ] )
2018-02-01 23:41:01 +01:00
. queryContext ( 'the context' )
2018-07-09 08:10:34 -04:00
. then ( ( res ) => {
2018-02-01 23:41:01 +01:00
expect ( res . queryContext ) . to . equal ( 'the context' ) ;
} ) ;
} ) ;
2017-10-12 18:16:15 +03:00
it ( 'should process response done in transaction' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex
. transaction ( ( trx ) => {
return trx ( 'accounts' )
. limit ( 1 )
. then ( ( res ) => {
expect ( res . callCount ) . to . equal ( 1 ) ;
return res ;
} ) ;
} )
. then ( ( res ) => {
2017-10-12 18:16:15 +03:00
expect ( res . callCount ) . to . equal ( 1 ) ;
} ) ;
} ) ;
2018-02-01 23:41:01 +01:00
it ( 'should pass query context for responses from transactions' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex
. transaction ( ( trx ) => {
return trx ( 'accounts' )
. queryContext ( 'the context' )
. limit ( 1 )
. then ( ( res ) => {
expect ( res . queryContext ) . to . equal ( 'the context' ) ;
return res ;
} ) ;
} )
. then ( ( res ) => {
expect ( res . queryContext ) . to . equal ( 'the context' ) ;
} ) ;
2018-02-01 23:41:01 +01:00
} ) ;
2020-08-08 15:57:58 +01:00
2020-08-08 10:27:47 -07:00
it ( 'should handle error correctly in a stream' , ( done ) => {
const stream = knex ( 'wrongtable' ) . limit ( 1 ) . stream ( ) ;
stream . on ( 'error' , ( ) => {
done ( ) ;
} ) ;
} ) ;
2020-08-08 15:57:58 +01:00
it ( 'should process response done through a stream' , ( done ) => {
let response ;
const stream = knex ( 'accounts' ) . limit ( 1 ) . stream ( ) ;
2020-08-08 10:27:47 -07:00
2020-08-08 15:57:58 +01:00
stream . on ( 'data' , ( res ) => {
response = res ;
} ) ;
stream . on ( 'finish' , ( ) => {
expect ( response . callCount ) . to . equal ( 1 ) ;
done ( ) ;
} ) ;
} ) ;
it ( 'should pass query context for responses through a stream' , ( done ) => {
let response ;
const stream = knex ( 'accounts' )
. queryContext ( 'the context' )
. limit ( 1 )
. stream ( ) ;
stream . on ( 'data' , ( res ) => {
response = res ;
} ) ;
stream . on ( 'finish' , ( ) => {
expect ( response . queryContext ) . to . equal ( 'the context' ) ;
done ( ) ;
} ) ;
} ) ;
it ( 'should process response for each row done through a stream' , ( done ) => {
const stream = knex ( 'accounts' ) . limit ( 5 ) . stream ( ) ;
let count = 0 ;
stream . on ( 'data' , ( ) => count ++ ) ;
stream . on ( 'finish' , ( ) => {
expect ( count ) . to . equal ( 5 ) ;
done ( ) ;
} ) ;
} ) ;
2017-10-12 18:16:15 +03:00
} ) ;
2018-01-03 00:05:48 +02:00
describe ( 'columnInfo with wrapIdentifier and postProcessResponse' , ( ) => {
before ( 'setup hooks' , ( ) => {
knex . client . config . postProcessResponse = ( response ) => {
return _ . mapKeys ( response , ( val , key ) => {
return _ . camelCase ( key ) ;
} ) ;
} ;
knex . client . config . wrapIdentifier = ( id , origImpl ) => {
return origImpl ( _ . snakeCase ( id ) ) ;
} ;
} ) ;
after ( 'restore client configuration' , ( ) => {
knex . client . config . postProcessResponse = null ;
knex . client . config . wrapIdentifier = null ;
} ) ;
it ( 'should work using camelCased table name' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex ( 'testTableTwo' )
. columnInfo ( )
. then ( ( res ) => {
expect ( Object . keys ( res ) ) . to . have . all . members ( [
'id' ,
'accountId' ,
'details' ,
'status' ,
'jsonData' ,
] ) ;
} ) ;
2018-01-03 00:05:48 +02:00
} ) ;
it ( 'should work using snake_cased table name' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex ( 'test_table_two' )
. columnInfo ( )
. then ( ( res ) => {
expect ( Object . keys ( res ) ) . to . have . all . members ( [
'id' ,
'accountId' ,
'details' ,
'status' ,
'jsonData' ,
] ) ;
} ) ;
2018-01-03 00:05:48 +02:00
} ) ;
} ) ;
2020-04-19 00:40:23 +02:00
describe ( 'returning with wrapIdentifier and postProcessResponse` (TODO: fix to work on all possible dialects)' , function ( ) {
2019-05-13 12:21:36 +03:00
const origHooks = { } ;
2021-03-08 07:16:07 -05:00
if ( ! isPostgreSQL ( knex ) || ! isMssql ( knex ) ) {
2019-05-13 12:21:36 +03:00
return ;
}
before ( 'setup custom hooks' , ( ) => {
origHooks . postProcessResponse = knex . client . config . postProcessResponse ;
origHooks . wrapIdentifier = knex . client . config . wrapIdentifier ;
// Add `_foo` to each identifier.
knex . client . config . postProcessResponse = ( res ) => {
if ( Array . isArray ( res ) ) {
return res . map ( ( it ) => {
if ( typeof it === 'object' ) {
return _ . mapKeys ( it , ( value , key ) => {
return key + '_foo' ;
} ) ;
} else {
return it ;
}
} ) ;
} else {
return res ;
}
} ;
2018-06-05 15:31:09 +03:00
2019-05-13 12:21:36 +03:00
// Remove `_foo` from the end of each identifier.
knex . client . config . wrapIdentifier = ( id ) => {
return id . substring ( 0 , id . length - 4 ) ;
} ;
} ) ;
2018-06-05 15:31:09 +03:00
2019-05-13 12:21:36 +03:00
after ( 'restore hooks' , ( ) => {
knex . client . config . postProcessResponse = origHooks . postProcessResponse ;
knex . client . config . wrapIdentifier = origHooks . wrapIdentifier ;
} ) ;
2018-06-05 15:31:09 +03:00
2019-05-13 12:21:36 +03:00
it ( 'should return the correct column when a single property is given to returning' , ( ) => {
return knex ( 'accounts_foo' )
. insert ( { balance _foo : 123 } )
. returning ( 'balance_foo' )
. then ( ( res ) => {
expect ( res ) . to . eql ( [ 123 ] ) ;
} ) ;
} ) ;
it ( 'should return the correct columns when multiple properties are given to returning' , ( ) => {
return knex ( 'accounts_foo' )
. insert ( { balance _foo : 123 , email _foo : 'foo@bar.com' } )
. returning ( [ 'balance_foo' , 'email_foo' ] )
. then ( ( res ) => {
expect ( res ) . to . eql ( [
{ balance _foo : 123 , email _foo : 'foo@bar.com' } ,
] ) ;
} ) ;
2018-06-05 15:31:09 +03:00
} ) ;
2019-05-13 12:21:36 +03:00
} ) ;
2018-06-05 15:31:09 +03:00
2020-04-19 00:40:23 +02:00
it ( 'should truncate a table with truncate' , function ( ) {
2013-09-12 01:00:44 -04:00
return knex ( 'test_table_two' )
. truncate ( )
2020-04-19 00:40:23 +02:00
. testSql ( function ( tester ) {
2013-12-27 14:44:21 -05:00
tester ( 'mysql' , 'truncate `test_table_two`' ) ;
2018-06-29 10:47:06 +03:00
tester ( 'pg' , 'truncate "test_table_two" restart identity' ) ;
2021-09-06 09:04:23 -04:00
tester ( 'pgnative' , 'truncate "test_table_two" restart identity' ) ;
2018-02-03 08:33:02 -05:00
tester ( 'pg-redshift' , 'truncate "test_table_two"' ) ;
2018-07-09 08:10:34 -04:00
tester ( 'sqlite3' , 'delete from `test_table_two`' ) ;
tester ( 'oracledb' , 'truncate table "test_table_two"' ) ;
2015-12-09 17:53:53 -06:00
tester ( 'mssql' , 'truncate table [test_table_two]' ) ;
2013-12-27 14:44:21 -05:00
} )
2017-11-24 08:00:20 +01:00
. then ( ( ) => {
2013-09-12 01:00:44 -04:00
return knex ( 'test_table_two' )
. select ( '*' )
2018-07-09 08:10:34 -04:00
. then ( ( resp ) => {
2013-09-12 01:00:44 -04:00
expect ( resp ) . to . have . length ( 0 ) ;
} ) ;
2017-11-24 08:00:20 +01:00
} )
. then ( ( ) => {
// Insert new data after truncate and make sure ids restart at 1.
// This doesn't currently work on oracle, where the created sequence
// needs to be manually reset.
2018-04-04 18:43:39 -04:00
// On redshift, one would need to create an entirely new table and do
// `insert into ... (select ...); alter table rename...`
2020-12-27 15:19:47 +02:00
if ( isOracle ( knex ) || isRedshift ( knex ) ) {
2018-07-09 08:10:34 -04:00
return ;
}
return knex ( 'test_table_two' )
. insert ( { status : 1 } )
. then ( ( res ) => {
2018-04-04 18:43:39 -04:00
return knex ( 'test_table_two' )
. select ( 'id' )
. first ( )
2018-07-09 08:10:34 -04:00
. then ( ( res ) => {
expect ( res ) . to . be . an ( 'object' ) ;
2018-04-04 18:43:39 -04:00
expect ( res . id ) . to . equal ( 1 ) ;
} ) ;
} ) ;
2013-09-12 01:00:44 -04:00
} ) ;
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'should allow raw queries directly with `knex.raw`' , function ( ) {
2018-11-19 12:55:50 +01:00
const tables = {
2021-03-08 07:16:07 -05:00
[ drivers . MySQL ] : 'SHOW TABLES' ,
[ drivers . MySQL2 ] : 'SHOW TABLES' ,
[ drivers . PostgreSQL ] :
2018-07-09 08:10:34 -04:00
"SELECT table_name FROM information_schema.tables WHERE table_schema='public'" ,
2021-09-06 09:04:23 -04:00
[ drivers . PgNative ] :
"SELECT table_name FROM information_schema.tables WHERE table_schema='public'" ,
2021-03-08 07:16:07 -05:00
[ drivers . Redshift ] :
2018-07-09 08:10:34 -04:00
"SELECT table_name FROM information_schema.tables WHERE table_schema='public'" ,
2021-03-08 07:16:07 -05:00
[ drivers . SQLite ] : "SELECT name FROM sqlite_master WHERE type='table';" ,
[ drivers . Oracle ] : 'select TABLE_NAME from USER_TABLES' ,
[ drivers . MsSQL ] :
2021-08-21 14:26:54 -04:00
"SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='dbo'" ,
2013-09-12 01:00:44 -04:00
} ;
2020-04-19 00:40:23 +02:00
return knex
. raw ( tables [ knex . client . driverName ] )
. testSql ( function ( tester ) {
tester ( knex . client . driverName , tables [ knex . client . driverName ] ) ;
} ) ;
2013-09-12 01:00:44 -04:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'should allow using the primary table as a raw statement' , function ( ) {
2018-07-09 08:10:34 -04:00
expect ( knex ( knex . raw ( 'raw_table_name' ) ) . toQuery ( ) ) . to . equal (
'select * from raw_table_name'
) ;
2014-04-21 23:08:59 -04:00
} ) ;
2013-09-12 01:00:44 -04:00
2020-04-19 00:40:23 +02:00
it ( 'should allow using .fn-methods to create raw statements' , function ( ) {
2014-07-03 11:59:29 +02:00
expect ( knex . fn . now ( ) . prototype === knex . raw ( ) . prototype ) ;
expect ( knex . fn . now ( ) . toQuery ( ) ) . to . equal ( 'CURRENT_TIMESTAMP' ) ;
2018-07-19 10:46:23 -04:00
expect ( knex . fn . now ( 6 ) . toQuery ( ) ) . to . equal ( 'CURRENT_TIMESTAMP(6)' ) ;
2014-07-03 11:59:29 +02:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'gets the columnInfo' , function ( ) {
2018-07-09 08:10:34 -04:00
return knex ( 'datatype_test' )
. columnInfo ( )
2020-04-19 00:40:23 +02:00
. testSql ( function ( tester ) {
2018-07-09 08:10:34 -04:00
tester (
'mysql' ,
'select * from information_schema.columns where table_name = ? and table_schema = ?' ,
null ,
{
enum _value : {
defaultValue : null ,
maxLength : 1 ,
nullable : true ,
type : 'enum' ,
} ,
uuid : {
defaultValue : null ,
maxLength : 36 ,
nullable : false ,
type : 'char' ,
} ,
2014-04-21 23:08:59 -04:00
}
2018-07-09 08:10:34 -04:00
) ;
tester (
'pg' ,
2021-08-20 11:51:21 +02:00
'select * from information_schema.columns where table_name = ? and table_catalog = current_database() and table_schema = current_schema()' ,
2018-07-09 08:10:34 -04:00
null ,
{
enum _value : {
defaultValue : null ,
maxLength : null ,
nullable : true ,
type : 'text' ,
} ,
uuid : {
defaultValue : null ,
maxLength : null ,
nullable : false ,
type : 'uuid' ,
} ,
}
) ;
2021-09-06 09:04:23 -04:00
tester (
'pgnative' ,
'select * from information_schema.columns where table_name = ? and table_catalog = current_database() and table_schema = current_schema()' ,
null ,
{
enum _value : {
defaultValue : null ,
maxLength : null ,
nullable : true ,
type : 'text' ,
} ,
uuid : {
defaultValue : null ,
maxLength : null ,
nullable : false ,
type : 'uuid' ,
} ,
}
) ;
2018-07-09 08:10:34 -04:00
tester (
'pg-redshift' ,
'select * from information_schema.columns where table_name = ? and table_catalog = ? and table_schema = current_schema()' ,
null ,
{
enum _value : {
defaultValue : null ,
maxLength : 255 ,
nullable : true ,
type : 'character varying' ,
} ,
uuid : {
defaultValue : null ,
maxLength : 36 ,
nullable : false ,
type : 'character' ,
} ,
}
) ;
tester ( 'sqlite3' , 'PRAGMA table_info(`datatype_test`)' , [ ] , {
enum _value : {
2018-07-08 14:10:51 +03:00
defaultValue : null ,
2018-07-09 08:10:34 -04:00
maxLength : null ,
2014-08-11 12:25:39 +02:00
nullable : true ,
2018-07-09 08:10:34 -04:00
type : 'text' ,
2014-08-11 12:25:39 +02:00
} ,
2018-07-09 08:10:34 -04:00
uuid : {
2018-07-08 14:10:51 +03:00
defaultValue : null ,
2018-07-09 08:10:34 -04:00
maxLength : '36' ,
2014-08-11 12:25:39 +02:00
nullable : false ,
2018-07-09 08:10:34 -04:00
type : 'char' ,
2015-12-09 17:53:53 -06:00
} ,
} ) ;
2018-07-09 08:10:34 -04:00
tester (
'oracledb' ,
2020-10-28 17:42:24 -03:00
"select * from xmltable( '/ROWSET/ROW'\n passing dbms_xmlgen.getXMLType('\n select char_col_decl_length, column_name, data_type, data_default, nullable\n from all_tab_columns where table_name = ''datatype_test'' ')\n columns\n CHAR_COL_DECL_LENGTH number, COLUMN_NAME varchar2(200), DATA_TYPE varchar2(106),\n DATA_DEFAULT clob, NULLABLE varchar2(1))" ,
2018-07-09 08:10:34 -04:00
[ ] ,
{
enum _value : {
defaultValue : null ,
nullable : true ,
maxLength : 1 ,
type : 'VARCHAR2' ,
} ,
uuid : {
defaultValue : null ,
nullable : false ,
maxLength : 36 ,
type : 'CHAR' ,
} ,
}
) ;
tester (
'mssql' ,
2021-08-21 14:26:54 -04:00
"select [COLUMN_NAME], [COLUMN_DEFAULT], [DATA_TYPE], [CHARACTER_MAXIMUM_LENGTH], [IS_NULLABLE] from INFORMATION_SCHEMA.COLUMNS where table_name = ? and table_catalog = ? and table_schema = 'dbo'" ,
2018-07-09 08:10:34 -04:00
[ 'datatype_test' , 'knex_test' ] ,
{
enum _value : {
defaultValue : null ,
maxLength : 100 ,
nullable : true ,
type : 'nvarchar' ,
} ,
uuid : {
defaultValue : null ,
maxLength : null ,
nullable : false ,
type : 'uniqueidentifier' ,
} ,
}
) ;
} ) ;
2013-09-12 01:00:44 -04:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'gets the columnInfo with columntype' , function ( ) {
2018-07-09 08:10:34 -04:00
return knex ( 'datatype_test' )
. columnInfo ( 'uuid' )
2020-04-19 00:40:23 +02:00
. testSql ( function ( tester ) {
2018-07-09 08:10:34 -04:00
tester (
'mysql' ,
'select * from information_schema.columns where table_name = ? and table_schema = ?' ,
null ,
{
defaultValue : null ,
maxLength : 36 ,
nullable : false ,
type : 'char' ,
}
) ;
tester (
'pg' ,
2021-08-20 11:51:21 +02:00
'select * from information_schema.columns where table_name = ? and table_catalog = current_database() and table_schema = current_schema()' ,
2018-07-09 08:10:34 -04:00
null ,
{
defaultValue : null ,
maxLength : null ,
nullable : false ,
type : 'uuid' ,
}
) ;
2021-09-06 09:04:23 -04:00
tester (
'pgnative' ,
'select * from information_schema.columns where table_name = ? and table_catalog = current_database() and table_schema = current_schema()' ,
null ,
{
defaultValue : null ,
maxLength : null ,
nullable : false ,
type : 'uuid' ,
}
) ;
2018-07-09 08:10:34 -04:00
tester (
'pg-redshift' ,
'select * from information_schema.columns where table_name = ? and table_catalog = ? and table_schema = current_schema()' ,
null ,
{
defaultValue : null ,
maxLength : 36 ,
nullable : false ,
type : 'character' ,
}
) ;
tester ( 'sqlite3' , 'PRAGMA table_info(`datatype_test`)' , [ ] , {
2018-07-08 14:10:51 +03:00
defaultValue : null ,
2018-07-09 08:10:34 -04:00
maxLength : '36' ,
2018-07-08 14:10:51 +03:00
nullable : false ,
2018-07-09 08:10:34 -04:00
type : 'char' ,
2015-12-09 17:53:53 -06:00
} ) ;
2018-07-09 08:10:34 -04:00
tester (
'oracledb' ,
2020-10-28 17:42:24 -03:00
"select * from xmltable( '/ROWSET/ROW'\n passing dbms_xmlgen.getXMLType('\n select char_col_decl_length, column_name, data_type, data_default, nullable\n from all_tab_columns where table_name = ''datatype_test'' ')\n columns\n CHAR_COL_DECL_LENGTH number, COLUMN_NAME varchar2(200), DATA_TYPE varchar2(106),\n DATA_DEFAULT clob, NULLABLE varchar2(1))" ,
2018-07-09 08:10:34 -04:00
[ ] ,
{
defaultValue : null ,
maxLength : 36 ,
nullable : false ,
type : 'CHAR' ,
}
) ;
tester (
'mssql' ,
2021-08-21 14:26:54 -04:00
"select [COLUMN_NAME], [COLUMN_DEFAULT], [DATA_TYPE], [CHARACTER_MAXIMUM_LENGTH], [IS_NULLABLE] from INFORMATION_SCHEMA.COLUMNS where table_name = ? and table_catalog = ? and table_schema = 'dbo'" ,
2018-07-09 08:10:34 -04:00
null ,
{
defaultValue : null ,
maxLength : null ,
nullable : false ,
type : 'uniqueidentifier' ,
}
) ;
} ) ;
2014-08-11 12:25:39 +02:00
} ) ;
2014-06-03 14:21:31 -04:00
2020-04-19 00:40:23 +02:00
it ( '#2184 - should properly escape table name for SQLite columnInfo' , function ( ) {
2020-12-27 15:19:47 +02:00
if ( ! isSQLite ( knex ) ) {
2020-03-01 19:04:01 -05:00
return this . skip ( ) ;
2017-10-23 09:13:09 +03:00
}
2018-07-09 08:10:34 -04:00
return knex . schema
. dropTableIfExists ( 'group' )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
return knex . schema . createTable ( 'group' , function ( table ) {
2017-10-23 09:13:09 +03:00
table . integer ( 'foo' ) ;
} ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2017-10-23 09:13:09 +03:00
return knex ( 'group' ) . columnInfo ( ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( columnInfo ) {
2017-10-23 09:13:09 +03:00
expect ( columnInfo ) . to . deep . equal ( {
foo : {
type : 'integer' ,
maxLength : null ,
nullable : true ,
defaultValue : null ,
} ,
} ) ;
} ) ;
} ) ;
2021-03-08 07:16:07 -05:00
if ( isOracle ( knex ) ) {
2019-09-22 16:31:56 -04:00
const oracledb = require ( 'oracledb' ) ;
2020-04-19 00:40:23 +02:00
describe ( 'test oracle stored procedures' , function ( ) {
it ( 'create stored procedure' , function ( ) {
2019-09-22 16:31:56 -04:00
return knex
. raw (
`
CREATE OR REPLACE PROCEDURE SYSTEM . multiply ( X IN NUMBER , Y IN NUMBER , OUTPUT OUT NUMBER )
IS
BEGIN
OUTPUT : = X * Y ;
END ; `
)
2020-04-19 00:40:23 +02:00
. then ( function ( result ) {
2019-09-22 16:31:56 -04:00
expect ( result ) . to . be . an ( 'array' ) ;
} ) ;
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'get outbound values from stored procedure' , function ( ) {
2019-09-22 16:31:56 -04:00
const bindVars = {
x : 6 ,
y : 7 ,
output : {
dir : oracledb . BIND _OUT ,
} ,
} ;
return knex
. raw ( 'BEGIN SYSTEM.MULTIPLY(:x, :y, :output); END;' , bindVars )
2020-04-19 00:40:23 +02:00
. then ( function ( result ) {
2019-09-22 16:31:56 -04:00
expect ( result [ 0 ] ) . to . be . ok ;
expect ( result [ 0 ] ) . to . equal ( '42' ) ;
} ) ;
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'drop stored procedure' , function ( ) {
2019-09-22 16:31:56 -04:00
const bindVars = { x : 6 , y : 7 } ;
return knex
. raw ( 'drop procedure SYSTEM.MULTIPLY' , bindVars )
2020-04-19 00:40:23 +02:00
. then ( function ( result ) {
2019-09-22 16:31:56 -04:00
expect ( result ) . to . be . ok ;
expect ( result ) . to . be . an ( 'array' ) ;
} ) ;
} ) ;
} ) ;
}
2020-04-19 00:40:23 +02:00
it ( 'should allow renaming a column' , function ( ) {
2018-11-19 12:55:50 +01:00
let countColumn ;
2021-03-08 07:16:07 -05:00
if ( isOracle ( knex ) ) {
countColumn = 'COUNT(*)' ;
} else if ( isMssql ( knex ) ) {
countColumn = '' ;
} else {
countColumn = 'count(*)' ;
2015-12-09 17:53:53 -06:00
}
2021-03-08 07:16:07 -05:00
2018-11-19 12:55:50 +01:00
let count ;
const inserts = [ ] ;
2020-04-19 00:40:23 +02:00
_ . times ( 40 , function ( i ) {
2018-07-09 08:10:34 -04:00
inserts . push ( {
email : 'email' + i ,
first _name : 'Test' ,
last _name : 'Data' ,
2013-09-12 01:00:44 -04:00
} ) ;
} ) ;
2018-07-09 08:10:34 -04:00
return knex ( 'accounts' )
. insert ( inserts )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-07-09 08:10:34 -04:00
return knex . count ( '*' ) . from ( 'accounts' ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( resp ) {
2018-07-09 08:10:34 -04:00
count = resp [ 0 ] [ countColumn ] ;
return knex . schema
2020-04-19 00:40:23 +02:00
. table ( 'accounts' , function ( t ) {
2018-07-09 08:10:34 -04:00
t . renameColumn ( 'about' , 'about_col' ) ;
} )
2020-04-19 00:40:23 +02:00
. testSql ( function ( tester ) {
2018-07-09 08:10:34 -04:00
tester ( 'mysql' , [ 'show fields from `accounts` where field = ?' ] ) ;
tester ( 'pg' , [
'alter table "accounts" rename "about" to "about_col"' ,
] ) ;
2021-09-06 09:04:23 -04:00
tester ( 'pgnative' , [
'alter table "accounts" rename "about" to "about_col"' ,
] ) ;
2018-07-09 08:10:34 -04:00
tester ( 'pg-redshift' , [
'alter table "accounts" rename "about" to "about_col"' ,
] ) ;
2021-01-03 22:49:12 +01:00
tester ( 'sqlite3' , [
'alter table `accounts` rename `about` to `about_col`' ,
] ) ;
2018-07-09 08:10:34 -04:00
tester ( 'oracledb' , [
'DECLARE PK_NAME VARCHAR(200); IS_AUTOINC NUMBER := 0; BEGIN EXECUTE IMMEDIATE (\'ALTER TABLE "accounts" RENAME COLUMN "about" TO "about_col"\'); SELECT COUNT(*) INTO IS_AUTOINC from "USER_TRIGGERS" where trigger_name = \'accounts_autoinc_trg\'; IF (IS_AUTOINC > 0) THEN SELECT cols.column_name INTO PK_NAME FROM all_constraints cons, all_cons_columns cols WHERE cons.constraint_type = \'P\' AND cons.constraint_name = cols.constraint_name AND cons.owner = cols.owner AND cols.table_name = \'accounts\'; IF (\'about_col\' = PK_NAME) THEN EXECUTE IMMEDIATE (\'DROP TRIGGER "accounts_autoinc_trg"\'); EXECUTE IMMEDIATE (\'create or replace trigger "accounts_autoinc_trg" BEFORE INSERT on "accounts" for each row declare checking number := 1; begin if (:new."about_col" is null) then while checking >= 1 loop select "accounts_seq".nextval into :new."about_col" from dual; select count("about_col") into checking from "accounts" where "about_col" = :new."about_col"; end loop; end if; end;\'); end if; end if;END;' ,
] ) ;
tester ( 'mssql' , [ "exec sp_rename ?, ?, 'COLUMN'" ] ) ;
} ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-07-09 08:10:34 -04:00
return knex . count ( '*' ) . from ( 'accounts' ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( resp ) {
2018-07-09 08:10:34 -04:00
expect ( resp [ 0 ] [ countColumn ] ) . to . equal ( count ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-07-09 08:10:34 -04:00
return knex ( 'accounts' ) . select ( 'about_col' ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
return knex . schema . table ( 'accounts' , function ( t ) {
2018-07-09 08:10:34 -04:00
t . renameColumn ( 'about_col' , 'about' ) ;
} ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-07-09 08:10:34 -04:00
return knex . count ( '*' ) . from ( 'accounts' ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( resp ) {
2018-07-09 08:10:34 -04:00
expect ( resp [ 0 ] [ countColumn ] ) . to . equal ( count ) ;
} ) ;
2013-09-12 01:00:44 -04:00
} ) ;
2014-06-09 15:28:22 -04:00
2020-04-19 00:40:23 +02:00
it ( 'should allow dropping a column' , function ( ) {
2018-11-19 12:55:50 +01:00
let countColumn ;
2021-03-08 07:16:07 -05:00
if ( isOracle ( knex ) ) {
countColumn = 'COUNT(*)' ;
} else if ( isMssql ( knex ) ) {
countColumn = '' ;
} else {
countColumn = 'count(*)' ;
2014-08-11 12:25:39 +02:00
}
2021-03-08 07:16:07 -05:00
2018-11-19 12:55:50 +01:00
let count ;
2018-07-09 08:10:34 -04:00
return knex
. count ( '*' )
. from ( 'accounts' )
2020-04-19 00:40:23 +02:00
. then ( function ( resp ) {
2018-07-09 08:10:34 -04:00
count = resp [ 0 ] [ countColumn ] ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-07-09 08:10:34 -04:00
return knex . schema
2020-04-19 00:40:23 +02:00
. table ( 'accounts' , function ( t ) {
2018-07-09 08:10:34 -04:00
t . dropColumn ( 'first_name' ) ;
} )
2020-04-19 00:40:23 +02:00
. testSql ( function ( tester ) {
2018-07-09 08:10:34 -04:00
tester ( 'mysql' , [ 'alter table `accounts` drop `first_name`' ] ) ;
tester ( 'pg' , [ 'alter table "accounts" drop column "first_name"' ] ) ;
2021-09-06 09:04:23 -04:00
tester ( 'pgnative' , [
'alter table "accounts" drop column "first_name"' ,
] ) ;
2018-07-09 08:10:34 -04:00
tester ( 'pg-redshift' , [
'alter table "accounts" drop column "first_name"' ,
] ) ;
tester ( 'sqlite3' , [ 'PRAGMA table_info(`accounts`)' ] ) ;
tester ( 'oracledb' , [
'alter table "accounts" drop ("first_name")' ,
] ) ;
//tester('oracledb', ['alter table "accounts" drop ("first_name")']);
tester ( 'mssql' , [
2020-05-15 11:28:34 +02:00
"\n DECLARE @constraint varchar(100) = (SELECT default_constraints.name\n FROM sys.all_columns\n INNER JOIN sys.tables\n ON all_columns.object_id = tables.object_id\n INNER JOIN sys.schemas\n ON tables.schema_id = schemas.schema_id\n INNER JOIN sys.default_constraints\n ON all_columns.default_object_id = default_constraints.object_id\n WHERE schemas.name = 'dbo'\n AND tables.name = 'accounts'\n AND all_columns.name = 'first_name')\n\n IF @constraint IS NOT NULL EXEC('ALTER TABLE accounts DROP CONSTRAINT ' + @constraint)" ,
2018-07-09 08:10:34 -04:00
'ALTER TABLE [accounts] DROP COLUMN [first_name]' ,
] ) ;
} ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
return knex . select ( '*' ) . from ( 'accounts' ) . first ( ) ;
2018-07-09 08:10:34 -04:00
} )
2020-04-19 00:40:23 +02:00
. then ( function ( resp ) {
2018-07-09 08:10:34 -04:00
expect ( _ . keys ( resp ) . sort ( ) ) . to . eql ( [
'about' ,
'balance' ,
'created_at' ,
'email' ,
'id' ,
'last_name' ,
'logins' ,
'phone' ,
'updated_at' ,
] ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-07-09 08:10:34 -04:00
return knex . count ( '*' ) . from ( 'accounts' ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( resp ) {
2018-07-09 08:10:34 -04:00
expect ( resp [ 0 ] [ countColumn ] ) . to . equal ( count ) ;
2014-06-09 15:28:22 -04:00
} ) ;
} ) ;
2020-04-19 00:40:23 +02:00
it ( '.timeout() should throw TimeoutError' , function ( ) {
2018-11-19 12:55:50 +01:00
const driverName = knex . client . driverName ;
2021-03-08 07:16:07 -05:00
if ( isSQLite ( knex ) ) {
2020-03-01 19:04:01 -05:00
return this . skip ( ) ;
2018-07-09 08:10:34 -04:00
} //TODO -- No built-in support for sleeps
2021-03-08 07:16:07 -05:00
if ( isRedshift ( knex ) ) {
2020-03-01 19:04:01 -05:00
return this . skip ( ) ;
2018-07-09 08:10:34 -04:00
}
2021-03-08 07:16:07 -05:00
2018-11-19 12:55:50 +01:00
const testQueries = {
2021-03-08 07:16:07 -05:00
[ drivers . PostgreSQL ] : function ( ) {
2016-03-08 13:07:50 +01:00
return knex . raw ( 'SELECT pg_sleep(1)' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . PgNative ] : function ( ) {
return knex . raw ( 'SELECT pg_sleep(1)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL ] : function ( ) {
2016-03-08 13:07:50 +01:00
return knex . raw ( 'SELECT SLEEP(1)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL2 ] : function ( ) {
2016-03-08 13:07:50 +01:00
return knex . raw ( 'SELECT SLEEP(1)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MsSQL ] : function ( ) {
2018-07-09 08:10:34 -04:00
return knex . raw ( "WAITFOR DELAY '00:00:01'" ) ;
2016-03-08 13:07:50 +01:00
} ,
2021-03-08 07:16:07 -05:00
[ drivers . Oracle ] : function ( ) {
2016-10-14 17:00:39 +02:00
return knex . raw ( 'begin dbms_lock.sleep(1); end;' ) ;
2018-07-09 08:10:34 -04:00
} ,
2016-03-08 13:07:50 +01:00
} ;
2016-02-15 17:06:08 +01:00
2019-07-10 20:47:56 +02:00
if ( ! Object . prototype . hasOwnProperty . call ( testQueries , driverName ) ) {
2018-07-08 14:10:51 +03:00
throw new Error ( 'Missing test query for driver: ' + driverName ) ;
2016-03-08 13:07:50 +01:00
}
2018-11-19 12:55:50 +01:00
const query = testQueries [ driverName ] ( ) ;
2016-03-08 13:07:50 +01:00
2018-07-09 08:10:34 -04:00
return query
. timeout ( 200 )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2016-02-15 17:06:08 +01:00
expect ( true ) . to . equal ( false ) ;
} )
2020-04-19 00:40:23 +02:00
. catch ( function ( error ) {
2016-02-15 17:06:08 +01:00
expect ( _ . pick ( error , 'timeout' , 'name' , 'message' ) ) . to . deep . equal ( {
2016-10-14 17:00:39 +02:00
timeout : 200 ,
2020-02-12 23:42:15 +03:00
name : 'KnexTimeoutError' ,
2018-07-09 08:10:34 -04:00
message :
'Defined query timeout of 200ms exceeded when running query.' ,
2016-02-15 17:06:08 +01:00
} ) ;
2018-07-09 08:10:34 -04:00
} ) ;
2016-05-26 11:06:33 -07:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( '.timeout(ms, {cancel: true}) should throw TimeoutError and cancel slow query' , function ( ) {
2020-12-27 15:19:47 +02:00
if ( isSQLite ( knex ) ) {
2020-03-01 19:04:01 -05:00
return this . skip ( ) ;
2018-07-09 08:10:34 -04:00
} //TODO -- No built-in support for sleeps
2020-12-27 15:19:47 +02:00
if ( isRedshift ( knex ) ) {
2020-03-01 19:04:01 -05:00
return this . skip ( ) ;
2018-07-09 08:10:34 -04:00
}
2016-05-26 11:06:33 -07:00
// There's unexpected behavior caused by knex releasing a connection back
// to the pool because of a timeout when a long query is still running.
// A subsequent query will acquire the connection (still in-use) and hang
// until the first query finishes. Setting a sleep time longer than the
// mocha timeout exposes this behavior.
2018-11-19 12:55:50 +01:00
const testQueries = {
2021-03-08 07:16:07 -05:00
[ drivers . PostgreSQL ] : function ( ) {
2016-05-26 11:06:33 -07:00
return knex . raw ( 'SELECT pg_sleep(10)' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . PgNative ] : function ( ) {
return knex . raw ( 'SELECT pg_sleep(10)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL ] : function ( ) {
2016-05-26 11:06:33 -07:00
return knex . raw ( 'SELECT SLEEP(10)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL2 ] : function ( ) {
2016-05-26 11:06:33 -07:00
return knex . raw ( 'SELECT SLEEP(10)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MsSQL ] : function ( ) {
2018-07-09 08:10:34 -04:00
return knex . raw ( "WAITFOR DELAY '00:00:10'" ) ;
2016-05-26 11:06:33 -07:00
} ,
2021-03-08 07:16:07 -05:00
[ drivers . Oracle ] : function ( ) {
2016-10-14 17:00:39 +02:00
return knex . raw ( 'begin dbms_lock.sleep(10); end;' ) ;
2018-07-09 08:10:34 -04:00
} ,
2016-05-26 11:06:33 -07:00
} ;
2020-12-27 15:19:47 +02:00
const driverName = knex . client . driverName ;
2019-07-10 20:47:56 +02:00
if ( ! Object . prototype . hasOwnProperty . call ( testQueries , driverName ) ) {
2018-07-08 14:10:51 +03:00
throw new Error ( 'Missing test query for driverName: ' + driverName ) ;
2016-05-26 11:06:33 -07:00
}
2018-11-19 12:55:50 +01:00
const query = testQueries [ driverName ] ( ) ;
2016-05-26 11:06:33 -07:00
2016-05-26 16:56:15 -07:00
function addTimeout ( ) {
2018-07-09 08:10:34 -04:00
return query . timeout ( 200 , { cancel : true } ) ;
2016-05-26 16:56:15 -07:00
}
2016-05-26 11:06:33 -07:00
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
// Only mysql/postgres query cancelling supported for now
2020-12-27 15:19:47 +02:00
if ( ! isMysql ( knex ) && ! isPostgreSQL ( knex ) ) {
2018-07-09 08:10:34 -04:00
expect ( addTimeout ) . to . throw (
'Query cancelling not supported for this dialect'
) ;
2020-03-01 19:04:01 -05:00
return ; // TODO: Use `this.skip()` here?
2016-05-26 11:06:33 -07:00
}
2018-11-19 12:55:50 +01:00
const getProcessesQueries = {
2021-03-08 07:16:07 -05:00
[ drivers . PostgreSQL ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knex . raw ( 'SELECT * from pg_stat_activity' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . PgNative ] : function ( ) {
return knex . raw ( 'SELECT * from pg_stat_activity' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knex . raw ( 'SHOW PROCESSLIST' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL2 ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knex . raw ( 'SHOW PROCESSLIST' ) ;
} ,
} ;
2019-07-10 20:47:56 +02:00
if (
! Object . prototype . hasOwnProperty . call ( getProcessesQueries , driverName )
) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
throw new Error ( 'Missing test query for driverName: ' + driverName ) ;
}
2018-11-19 12:55:50 +01:00
const getProcessesQuery = getProcessesQueries [ driverName ] ( ) ;
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
2016-05-26 11:06:33 -07:00
return addTimeout ( )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2016-05-26 11:06:33 -07:00
expect ( true ) . to . equal ( false ) ;
} )
2020-04-19 00:40:23 +02:00
. catch ( function ( error ) {
2016-05-26 11:06:33 -07:00
expect ( _ . pick ( error , 'timeout' , 'name' , 'message' ) ) . to . deep . equal ( {
2016-10-14 17:00:39 +02:00
timeout : 200 ,
2020-02-12 23:42:15 +03:00
name : 'KnexTimeoutError' ,
2018-07-09 08:10:34 -04:00
message :
'Defined query timeout of 200ms exceeded when running query.' ,
2016-05-26 11:06:33 -07:00
} ) ;
// Ensure sleep command is removed.
// This query will hang if a connection gets released back to the pool
2017-10-12 18:16:15 +03:00
// too early.
2016-11-29 10:13:30 +02:00
// 50ms delay since killing query doesn't seem to have immediate effect to the process listing
2020-02-25 03:24:30 +03:00
return delay ( 50 )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return getProcessesQuery ;
2016-11-29 10:13:30 +02:00
} )
2020-04-19 00:40:23 +02:00
. then ( function ( results ) {
2018-11-19 12:55:50 +01:00
let processes ;
let sleepProcess ;
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
2021-03-08 07:16:07 -05:00
if ( isPgBased ( knex ) ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
processes = results . rows ;
sleepProcess = _ . find ( processes , { query : query . toString ( ) } ) ;
} else {
processes = results [ 0 ] ;
sleepProcess = _ . find ( processes , {
Info : 'SELECT SLEEP(10)' ,
} ) ;
}
2016-05-26 11:06:33 -07:00
expect ( sleepProcess ) . to . equal ( undefined ) ;
} ) ;
2016-02-15 17:06:08 +01:00
} ) ;
} ) ;
2021-03-22 00:33:59 +01:00
it ( '.timeout(ms, {cancel: true}) should throw TimeoutError and cancel slow query in transaction' , function ( ) {
const driverName = knex . client . driverName ;
if ( driverName === 'sqlite3' ) {
return this . skip ( ) ;
} //TODO -- No built-in support for sleeps
if ( /redshift/ . test ( driverName ) ) {
return this . skip ( ) ;
}
// There's unexpected behavior caused by knex releasing a connection back
// to the pool because of a timeout when a long query is still running.
// A subsequent query will acquire the connection (still in-use) and hang
// until the first query finishes. Setting a sleep time longer than the
// mocha timeout exposes this behavior.
const testQueries = {
2021-09-06 09:04:23 -04:00
[ drivers . PostgreSQL ] : function ( ) {
return knex . raw ( 'SELECT pg_sleep(10)' ) ;
} ,
[ drivers . PgNative ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( 'SELECT pg_sleep(10)' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . MySQL ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( 'SELECT SLEEP(10)' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . MySQL2 ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( 'SELECT SLEEP(10)' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . MsSQL ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( "WAITFOR DELAY '00:00:10'" ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . Oracle ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( 'begin dbms_lock.sleep(10); end;' ) ;
} ,
} ;
if ( ! Object . prototype . hasOwnProperty . call ( testQueries , driverName ) ) {
throw new Error ( 'Missing test query for driverName: ' + driverName ) ;
}
const query = testQueries [ driverName ] ( ) ;
function addTimeout ( ) {
return query . timeout ( 200 , { cancel : true } ) ;
}
// Only mysql/postgres query cancelling supported for now
if (
! _ . startsWith ( driverName , 'mysql' ) &&
! _ . startsWith ( driverName , 'pg' )
) {
expect ( addTimeout ) . to . throw (
'Query cancelling not supported for this dialect'
) ;
return ; // TODO: Use `this.skip()` here?
}
const getProcessesQueries = {
2021-09-06 09:04:23 -04:00
[ drivers . PostgreSQL ] : function ( ) {
return knex . raw ( 'SELECT * from pg_stat_activity' ) ;
} ,
[ drivers . PgNative ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( 'SELECT * from pg_stat_activity' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . MySQL ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( 'SHOW PROCESSLIST' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . MySQL2 ] : function ( ) {
2021-03-22 00:33:59 +01:00
return knex . raw ( 'SHOW PROCESSLIST' ) ;
} ,
} ;
if (
! Object . prototype . hasOwnProperty . call ( getProcessesQueries , driverName )
) {
throw new Error ( 'Missing test query for driverName: ' + driverName ) ;
}
const getProcessesQuery = getProcessesQueries [ driverName ] ( ) ;
2021-08-20 11:51:21 +02:00
return knex
. transaction ( ( trx ) => addTimeout ( ) . transacting ( trx ) )
2021-03-22 00:33:59 +01:00
. then ( function ( ) {
expect ( true ) . to . equal ( false ) ;
} )
. catch ( function ( error ) {
expect ( _ . pick ( error , 'timeout' , 'name' , 'message' ) ) . to . deep . equal ( {
timeout : 200 ,
name : 'KnexTimeoutError' ,
message :
'Defined query timeout of 200ms exceeded when running query.' ,
} ) ;
// Ensure sleep command is removed.
// This query will hang if a connection gets released back to the pool
// too early.
// 50ms delay since killing query doesn't seem to have immediate effect to the process listing
return delay ( 50 )
. then ( function ( ) {
return getProcessesQuery ;
} )
. then ( function ( results ) {
let processes ;
let sleepProcess ;
if ( _ . startsWith ( driverName , 'pg' ) ) {
processes = results . rows ;
sleepProcess = _ . find ( processes , { query : query . toString ( ) } ) ;
} else {
processes = results [ 0 ] ;
sleepProcess = _ . find ( processes , {
Info : 'SELECT SLEEP(10)' ,
} ) ;
}
expect ( sleepProcess ) . to . equal ( undefined ) ;
} ) ;
} ) ;
} ) ;
it ( '.timeout(ms, {cancel: true}) should cancel slow query even if connection pool is exhausted' , async function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
// Only mysql/postgres query cancelling supported for now
2020-12-27 15:19:47 +02:00
if ( ! isMysql ( knex ) && ! isPostgreSQL ( knex ) ) {
2020-03-01 19:04:01 -05:00
return this . skip ( ) ;
2016-09-13 18:12:23 -04:00
}
2016-05-26 16:56:15 -07:00
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
// To make this test easier, I'm changing the pool settings to max 1.
// Also setting acquireTimeoutMillis to lower as not to wait the default time
2018-11-19 12:55:50 +01:00
const knexConfig = _ . cloneDeep ( knex . client . config ) ;
2016-05-26 16:56:15 -07:00
knexConfig . pool . min = 0 ;
knexConfig . pool . max = 1 ;
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
knexConfig . pool . acquireTimeoutMillis = 100 ;
2016-05-26 16:56:15 -07:00
2018-11-19 12:55:50 +01:00
const knexDb = new Knex ( knexConfig ) ;
2016-05-26 16:56:15 -07:00
2018-11-19 12:55:50 +01:00
const testQueries = {
2021-03-08 07:16:07 -05:00
[ drivers . PostgreSQL ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knexDb . raw ( 'SELECT pg_sleep(10)' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . PgNative ] : function ( ) {
return knexDb . raw ( 'SELECT pg_sleep(10)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knexDb . raw ( 'SELECT SLEEP(10)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MySQL2 ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knexDb . raw ( 'SELECT SLEEP(10)' ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . MsSQL ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knexDb . raw ( "WAITFOR DELAY '00:00:10'" ) ;
} ,
2021-03-08 07:16:07 -05:00
[ drivers . Oracle ] : function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
return knexDb . raw ( 'begin dbms_lock.sleep(10); end;' ) ;
} ,
} ;
2020-12-27 15:19:47 +02:00
const driverName = knex . client . driverName ;
2019-07-10 20:47:56 +02:00
if ( ! Object . prototype . hasOwnProperty . call ( testQueries , driverName ) ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
throw new Error ( 'Missing test query for dialect: ' + driverName ) ;
}
2018-11-19 12:55:50 +01:00
const query = testQueries [ driverName ] ( ) ;
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
2021-03-22 00:33:59 +01:00
// We must use the original knex instance without the exhausted pool to list running queries
const getProcessesForDriver = {
2021-09-06 09:04:23 -04:00
[ drivers . PostgreSQL ] : async ( ) => {
const results = await knex . raw ( 'SELECT * from pg_stat_activity' ) ;
return _ . map ( _ . filter ( results . rows , { state : 'active' } ) , 'query' ) ;
} ,
[ drivers . PgNative ] : async ( ) => {
2021-03-22 00:33:59 +01:00
const results = await knex . raw ( 'SELECT * from pg_stat_activity' ) ;
2021-08-20 11:51:21 +02:00
return _ . map ( _ . filter ( results . rows , { state : 'active' } ) , 'query' ) ;
2021-03-22 00:33:59 +01:00
} ,
2021-09-06 09:04:23 -04:00
[ drivers . MySQL ] : async ( ) => {
2021-03-22 00:33:59 +01:00
const results = await knex . raw ( 'SHOW PROCESSLIST' ) ;
return _ . map ( results [ 0 ] , 'Info' ) ;
} ,
2021-09-06 09:04:23 -04:00
[ drivers . MySQL2 ] : async ( ) => {
2021-03-22 00:33:59 +01:00
const results = await knex . raw ( 'SHOW PROCESSLIST' ) ;
return _ . map ( results [ 0 ] , 'Info' ) ;
} ,
} ;
if (
! Object . prototype . hasOwnProperty . call ( getProcessesForDriver , driverName )
) {
throw new Error ( 'Missing test query for driverName: ' + driverName ) ;
}
const getProcesses = getProcessesForDriver [ driverName ] ;
2020-02-25 03:24:30 +03:00
try {
2021-08-20 11:51:21 +02:00
const promise = query . timeout ( 50 , { cancel : true } ) . then ( _ . identity ) ;
2021-03-22 00:33:59 +01:00
2021-09-06 09:04:23 -04:00
await delay ( 15 ) ;
2021-03-22 00:33:59 +01:00
const processesBeforeTimeout = await getProcesses ( ) ;
2021-08-20 11:51:21 +02:00
expect ( processesBeforeTimeout ) . to . include ( query . toString ( ) ) ;
2021-03-22 00:33:59 +01:00
await expect ( promise ) . to . eventually . be . rejected . and . to . deep . include ( {
timeout : 50 ,
2020-02-25 03:24:30 +03:00
name : 'KnexTimeoutError' ,
2021-03-22 00:33:59 +01:00
message : 'Defined query timeout of 50ms exceeded when running query.' ,
2020-02-25 03:24:30 +03:00
} ) ;
2021-03-22 00:33:59 +01:00
const processesAfterTimeout = await getProcesses ( ) ;
2021-08-20 11:51:21 +02:00
expect ( processesAfterTimeout ) . to . not . include ( query . toString ( ) ) ;
2020-02-25 03:24:30 +03:00
} finally {
await knexDb . destroy ( ) ;
}
2016-05-26 16:56:15 -07:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( '.timeout(ms, {cancel: true}) should release connections after failing if connection cancellation throws an error' , async function ( ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
// Only mysql/postgres query cancelling supported for now
2021-09-06 09:04:23 -04:00
if ( ! isPostgreSQL ( knex ) || isPgNative ( knex ) ) {
2020-03-01 19:04:01 -05:00
return this . skip ( ) ;
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
}
// To make this test easier, I'm changing the pool settings to max 1.
// Also setting acquireTimeoutMillis to lower as not to wait the default time
2018-11-19 12:55:50 +01:00
const knexConfig = _ . cloneDeep ( knex . client . config ) ;
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
knexConfig . pool . min = 0 ;
knexConfig . pool . max = 2 ;
knexConfig . pool . acquireTimeoutMillis = 100 ;
2018-11-19 12:55:50 +01:00
const rawTestQueries = {
2021-03-08 07:16:07 -05:00
[ drivers . PostgreSQL ] : ( sleepSeconds ) =>
` SELECT pg_sleep( ${ sleepSeconds } ) ` ,
2021-09-06 09:04:23 -04:00
[ drivers . PgNative ] : ( sleepSeconds ) =>
` SELECT pg_sleep( ${ sleepSeconds } ) ` ,
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
} ;
2020-12-27 15:19:47 +02:00
const driverName = knex . client . driverName ;
2019-07-10 20:47:56 +02:00
if ( ! Object . prototype . hasOwnProperty . call ( rawTestQueries , driverName ) ) {
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
throw new Error ( 'Missing test query for driverName: ' + driverName ) ;
}
2020-02-25 03:24:30 +03:00
const knexDb = new Knex ( knexConfig ) ;
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
const getTestQuery = ( sleepSeconds = 10 ) => {
const rawTestQuery = rawTestQueries [ driverName ] ( sleepSeconds ) ;
return knexDb . raw ( rawTestQuery ) ;
} ;
const knexPrototype = Object . getPrototypeOf ( knexDb . client ) ;
const originalWrappedCancelQueryCall =
knexPrototype . _wrappedCancelQueryCall ;
2020-02-25 03:24:30 +03:00
2021-09-06 09:04:23 -04:00
knexPrototype . _wrappedCancelQueryCall = ( conn , connectionToKill ) => {
if ( isPgNative ( knex ) ) {
throw new Error ( 'END THIS' ) ;
} else {
return knexPrototype . query ( conn , {
method : 'raw' ,
sql : 'TestError' ,
} ) ;
}
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
} ;
const queryTimeout = 10 ;
const secondQueryTimeout = 11 ;
2020-02-25 03:24:30 +03:00
try {
await expect (
getTestQuery ( ) . timeout ( queryTimeout , { cancel : true } )
) . to . be . eventually . rejected . and . deep . include ( {
timeout : queryTimeout ,
name : 'error' ,
message : ` After query timeout of ${ queryTimeout } ms exceeded, cancelling of query failed. ` ,
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
} ) ;
2020-02-25 03:24:30 +03:00
knexPrototype . _wrappedCancelQueryCall = originalWrappedCancelQueryCall ;
await expect (
getTestQuery ( ) . timeout ( secondQueryTimeout , { cancel : true } )
) . to . be . eventually . rejected . and . deep . include ( {
timeout : secondQueryTimeout ,
name : 'KnexTimeoutError' ,
message : ` Defined query timeout of ${ secondQueryTimeout } ms exceeded when running query. ` ,
} ) ;
} finally {
await knexDb . destroy ( ) ;
}
Kill queries after timeout for PostgreSQL (#2636)
* Kill queries after timeout for PostgreSQL
* Fix cancellation connection acquiring and test.
* Fix releasing connection in case query cancellation fails
* Add support for native enums on Postgres (#2632)
Reference https://www.postgresql.org/docs/current/static/sql-createtype.html
Closes #394
Signed-off-by: Will Soto <will.soto9@gmail.com>
* Removal of 'skim' (#2520)
* Allow overwriting log functions (#2625)
* Example build of custom log functions
* Handle logger object better for transactions
* Adjust test to ignore sqlite warning message
* Fixed onIn with empty values array (#2513)
* Drop support for strong-oracle (#2487)
* Remove babel-plugin-lodash (#2634)
While in theory, this may reduce the bundle size,
in practice it adds a ton of overhead during startup
due to the number of additional requires. Bundle
size also shouldn't matter for server side modules.
* Add json support to the query builder for mysql (#2635)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* fix wrapIdentifier not being called in postgres alter column (#2612)
* fix wrapIdentifier not being called in postgres alter column
* add test for wrapIdentifier call in postgres alter column
* add comment regarding issue
* add issue & PR #'s in comment
* Remove readable-stream and safe-buffer (#2640)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* fixes 2630 (#2642)
* Timeout errors shouldn't silently ignore the passed errors, but rather reject with original error. Fixes #2582 (#2626)
* chore: add Node.js 10 (#2594)
* chore: add Node.js 10
* chore: trigger new build
* chore: update lockfile
* chore: trigger new build
* fix: use npm i instead of npm ci
* Fix mssql driver crashing (#2637)
* Run SQL Server tests locally running SQL server in docker
* WIP mssql test stuff
* Patched MSSQL driver to not crash knex anymore
* Removed semicolon from rollback stmt for oracle (#2564)
* Remove WebSQL dialect (#2647)
* Add json support to the query builder for mysql
refs #1036
Based on #1902
* Clarify supported version
* Use native Buffer and Stream implementations
* Remove WebSQL dialect
* add homepage field to package.json (#2650)
* Make the stream catch errors in the query (#2638)
* Make the stream catch errors in the query
* Fix another case in which stream doesnt emits error
* Linter stuff
* Remove setTimeout in tests
* Make a test not to check the MySQL error code
* Fix stream error catching for MariaDB and PostgreSQL
* Fix stream error catching in Oracle
* Throw the error after emitting it to the stream
* Throw the error without instantiating a new Error
* Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float
* Many tests where postgres test was not actually ran at all
* Migrations to be mssql compatible
Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.
* Prevented mssql failing when invalid schema builder was executed by accident
Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started
* Fixed mssql trx rollback to always throw an error
Also modified some connection test query to be mssql compatible
* Fixed various bugs from MSSQL driver to make tests run
* Fixed mssql unique index to be compatible with other dialect implementations
* Enable running mssql tests on CI
* Test for #2588
* Updated tests to not be dependend on tables left from previous test rans
* Trying to make mssql server work on travis
* Updated changelog and version
* Drop mariadb support (#2681)
* Dropped support for mariasql
* ESLint
* Fixed docs to build again
* Fix knex.initialize() and adds test (#2477)
* Fix knex.initialize() and adds test
* Fix knex.initialize() and adds test
* Added test for reinitializing pool after destroy
* Fixed destroy / reinitialization test
* Fixed the fix
* Implement missing schema support for mssql dialect
* chore: Update dependencies. Remove estraverse (#2691)
* Update dependencies. Remove estraverse
* Fix compatibility with new Sinon
* Increase mssql timeout
* Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup
* Fixed failed queries from old query building tests which hadn't been ran in ages
* Allow selecting node version which is used to run oracledb docker tests
* Improved sql tester error messages
* Fixed rest of the oracledb tests
* Removed invalid flag from docker-compose
* Print mssql logs if initialization fails
* Fixed syntax error + final tests
* Added restart of failure for mssql DB initialization to try again if server was not ready
* Printout always mssql logs after container is started
* Fixed wait time printing after trying to connect
* Use npm run oracledb:test for testing oracle in travis
* Add Prettier (#2697)
* Add prettier
* Run files through prettier
* Istanbul -> NYC (#2700)
* istanbul -> nyc
* Update mocha
* Enforce code coverage (#2702)
* Enforce code coverage
* Update coverage numbers with current values
* version assignment on base class, copy on tx client, fix #2705
* Update changelog
* v0.15.1
* Added build step to test script. Fixes #2541 (#2712)
* Revert "Added build step to test script. Fixes #2541 (#2712)" (#2714)
This reverts commit 90ed8db58053b859a6bdc45a17f2f510ce8a3411.
* Allow oracle failures for now
* Fix issue with select(0) (#2711)
* Fix issue with select(0). Fixes #2658
* Refactor migrator (#2695)
* Refactor migrator
* Fix exports
* Fix ESLint
* Fix migrator
* Fix reference to config
* Split some more
* Fix table builder
* Fix argument order
* Merge branch 'master' of https://github.com/tgriesser/knex into feature/2690-support-multiple-migration-dirs
# Conflicts:
# src/migrate/index.js
# test/index.js
# test/unit/migrate/migrator.js
* Fix #2715 (#2721)
* Fix #2715, explicitly set precision in datetime & timestamp
* Allow for precision in knex.fn.now, mysql time
* Add test for datetime with precision
* Bump changelog
* 0.15.2
* Fix issues with warnPromise when migration does not return a promise. Fixes #2725 (#2730)
* Add tests for multiple union arguments with callbacks and builders (#2749)
* Add tests for multiple union arguments
* Add some callback and raw tests to union unit tests
* Compile with before update so that bindings are put in correct order (#2733)
* Fix join using builder withSchema. (#2744)
* Use Datetime2 for MSSQL datetime + timestamp types (#2757)
* Use Datetime2 for MSSQL datetime + timestamp types
Datetime2 is now the recommended column type for new date work: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-2017
* Add tests for MSSQL datetime2 changes
* General/document breaking change (#2774)
* Add changelog entry for a breaking change
* Improve entry
* Allow timestamp with timezone on mssql databases (#2724)
* Allow timestamp with timezone on mssql databases
* Change timestamp parameter to use object instead of boolean
* Update dependencies (#2772)
* Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories
* Add tests for new functionality
* Fix tape tests
* Pass migration directory upwards
* Fix multiple directory support
* Fix bugs
* Rollback correctly
* Fix remaining tests
* Address comments
* #2758: Implement fail-fast logic for dialect resolution (#2776)
* Implement fail-fast logic for dialect resolution, clean-up code around.
* Remove method that was deprecated long time ago
* Address additional comments
* Try addressing comments
* Set client explicitly
* Fix compatibility with older Node versions
* Use columnize instead of wrap in using(). (#2713)
* Use columnize instead of wrap in using().
This is an attempt to fix #2136. Also added an integration test, couldn't find any existing.
* Exclude MSSQL from test as it does not support .using
* Change test to not use subquery
* Change test
* Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations
This would allow a webpack migration source which is compatible with bundling.
* Fixed migration validation with custom migration source
* Fixed issues after rebasing on muti directory PR
* Renamed parameter and fixed error message
* Addressed some PR comments
* Finished comment
* Moved filename extension filtering into fs-migrator
* Added test showing in memory custom migration source
* Cleaned up how to get config
* Fixed failing test
* Hopefully fix tests
* Fix Node.js 10 support in tests
* Test for correctly releasing cancel query connection
2018-09-27 00:06:43 +03:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'Event: query-response' , function ( ) {
2018-11-19 12:55:50 +01:00
let queryCount = 0 ;
2016-02-26 19:51:35 +01:00
2020-04-19 00:40:23 +02:00
const onQueryResponse = function ( response , obj , builder ) {
2016-02-26 19:51:35 +01:00
queryCount ++ ;
2016-02-26 20:32:34 +01:00
expect ( response ) . to . be . an ( 'array' ) ;
2016-02-26 20:01:18 +01:00
expect ( obj ) . to . be . an ( 'object' ) ;
expect ( obj . _ _knexUid ) . to . be . a ( 'string' ) ;
2016-06-17 09:53:54 -07:00
expect ( obj . _ _knexQueryUid ) . to . be . a ( 'string' ) ;
2016-02-26 20:01:18 +01:00
expect ( builder ) . to . be . an ( 'object' ) ;
2016-03-24 18:59:37 +01:00
} ;
knex . on ( 'query-response' , onQueryResponse ) ;
2016-02-26 19:51:35 +01:00
2018-07-09 08:10:34 -04:00
return knex ( 'accounts' )
. select ( )
2016-03-24 18:59:37 +01:00
. on ( 'query-response' , onQueryResponse )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
return knex . transaction ( function ( tr ) {
2018-07-09 08:10:34 -04:00
return tr ( 'accounts' )
. select ( )
. on ( 'query-response' , onQueryResponse ) ; //Transactions should emit the event as well
} ) ;
2016-02-26 19:51:35 +01:00
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2017-10-12 18:16:15 +03:00
knex . removeListener ( 'query-response' , onQueryResponse ) ;
2016-03-24 18:59:37 +01:00
expect ( queryCount ) . to . equal ( 4 ) ;
2018-07-09 08:10:34 -04:00
} ) ;
2016-03-24 18:59:37 +01:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'Event: preserves listeners on a copy with user params' , function ( ) {
2018-11-19 12:55:50 +01:00
let queryCount = 0 ;
2018-09-26 22:27:59 +02:00
2020-04-19 00:40:23 +02:00
const onQueryResponse = function ( response , obj , builder ) {
2016-03-24 18:59:37 +01:00
queryCount ++ ;
2018-09-26 22:27:59 +02:00
expect ( response ) . to . be . an ( 'array' ) ;
expect ( obj ) . to . be . an ( 'object' ) ;
expect ( obj . _ _knexUid ) . to . be . a ( 'string' ) ;
expect ( obj . _ _knexQueryUid ) . to . be . a ( 'string' ) ;
expect ( builder ) . to . be . an ( 'object' ) ;
} ;
knex . on ( 'query-response' , onQueryResponse ) ;
const knexCopy = knex . withUserParams ( { } ) ;
return knexCopy ( 'accounts' )
. select ( )
. on ( 'query-response' , onQueryResponse )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
return knexCopy . transaction ( function ( tr ) {
2018-09-26 22:27:59 +02:00
return tr ( 'accounts' )
. select ( )
. on ( 'query-response' , onQueryResponse ) ; //Transactions should emit the event as well
} ) ;
} )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-09-26 22:27:59 +02:00
expect ( Object . keys ( knex . _events ) . length ) . to . equal ( 1 ) ;
2019-01-31 06:23:05 +01:00
expect ( Object . keys ( knexCopy . _events ) . length ) . to . equal ( 1 ) ;
2018-09-26 22:27:59 +02:00
knex . removeListener ( 'query-response' , onQueryResponse ) ;
expect ( Object . keys ( knex . _events ) . length ) . to . equal ( 0 ) ;
expect ( queryCount ) . to . equal ( 4 ) ;
} ) ;
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'Event: query-error' , function ( ) {
2018-11-19 12:55:50 +01:00
let queryCountKnex = 0 ;
let queryCountBuilder = 0 ;
2020-04-19 00:40:23 +02:00
const onQueryErrorKnex = function ( error , obj ) {
2018-09-26 22:27:59 +02:00
queryCountKnex ++ ;
expect ( obj ) . to . be . an ( 'object' ) ;
expect ( obj . _ _knexUid ) . to . be . a ( 'string' ) ;
expect ( obj . _ _knexQueryUid ) . to . be . a ( 'string' ) ;
expect ( error ) . to . be . an ( 'error' ) ;
} ;
2020-04-19 00:40:23 +02:00
const onQueryErrorBuilder = function ( error , obj ) {
2018-09-26 22:27:59 +02:00
queryCountBuilder ++ ;
2016-03-24 18:59:37 +01:00
expect ( obj ) . to . be . an ( 'object' ) ;
expect ( obj . _ _knexUid ) . to . be . a ( 'string' ) ;
2016-06-17 09:53:54 -07:00
expect ( obj . _ _knexQueryUid ) . to . be . a ( 'string' ) ;
2018-09-26 22:27:59 +02:00
expect ( error ) . to . be . an ( 'error' ) ;
2016-03-24 18:59:37 +01:00
} ;
2018-09-26 22:27:59 +02:00
knex . on ( 'query-error' , onQueryErrorKnex ) ;
2016-03-24 18:59:37 +01:00
2018-07-09 08:10:34 -04:00
return knex
. raw ( 'Broken query' )
2018-09-26 22:27:59 +02:00
. on ( 'query-error' , onQueryErrorBuilder )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2016-03-24 18:59:37 +01:00
expect ( true ) . to . equal ( false ) ; //Should not be resolved
} )
2020-04-19 00:40:23 +02:00
. catch ( function ( ) {
2018-09-26 22:27:59 +02:00
knex . removeListener ( 'query-error' , onQueryErrorKnex ) ;
knex . removeListener ( 'query-error' , onQueryErrorBuilder ) ;
expect ( queryCountBuilder ) . to . equal ( 1 ) ;
expect ( queryCountKnex ) . to . equal ( 1 ) ;
2018-07-09 08:10:34 -04:00
} ) ;
2016-02-26 19:51:35 +01:00
} ) ;
2020-04-19 00:40:23 +02:00
it ( 'Event: start' , function ( ) {
2018-02-19 10:13:10 +01:00
return knex ( 'accounts' )
2018-07-09 08:10:34 -04:00
. insert ( { last _name : 'Start event test' } )
2020-04-19 00:40:23 +02:00
. then ( function ( ) {
2018-11-19 12:55:50 +01:00
const queryBuilder = knex ( 'accounts' ) . select ( ) ;
2018-02-19 10:13:10 +01:00
2020-04-19 00:40:23 +02:00
queryBuilder . on ( 'start' , function ( builder ) {
2018-02-19 10:13:10 +01:00
//Alter builder prior to compilation
//Select only one row
2018-07-09 08:10:34 -04:00
builder . where ( 'last_name' , 'Start event test' ) . first ( ) ;
2018-02-19 10:13:10 +01:00
} ) ;
2018-07-09 08:10:34 -04:00
return queryBuilder ;
2018-02-19 10:13:10 +01:00
} )
2020-04-19 00:40:23 +02:00
. then ( function ( row ) {
2018-02-19 10:13:10 +01:00
expect ( row ) . to . exist ;
2018-06-29 10:47:06 +03:00
expect ( row . last _name ) . to . equal ( 'Start event test' ) ;
2018-02-19 10:13:10 +01:00
} ) ;
} ) ;
2020-04-19 00:40:23 +02:00
it ( "Event 'query' should not emit native sql string" , function ( ) {
const builder = knex ( 'accounts' ) . where ( 'id' , 1 ) . select ( ) ;
2018-04-12 09:17:45 +02:00
2020-04-19 00:40:23 +02:00
builder . on ( 'query' , function ( obj ) {
2018-11-19 12:55:50 +01:00
const native = builder . toSQL ( ) . toNative ( ) . sql ;
const sql = builder . toSQL ( ) . sql ;
2018-04-12 09:17:45 +02:00
2018-07-09 08:10:34 -04:00
//Only assert if they diff to begin with.
//IE Maria does not diff
if ( native !== sql ) {
expect ( obj . sql ) . to . not . equal ( builder . toSQL ( ) . toNative ( ) . sql ) ;
expect ( obj . sql ) . to . equal ( builder . toSQL ( ) . sql ) ;
}
} ) ;
2018-04-12 09:17:45 +02:00
return builder ;
} ) ;
2020-04-19 00:40:23 +02:00
describe ( 'async stack traces' , function ( ) {
2018-04-25 23:11:24 +02:00
before ( ( ) => {
2018-07-09 08:10:34 -04:00
knex . client . config . asyncStackTraces = true ;
} ) ;
2018-04-25 23:11:24 +02:00
after ( ( ) => {
2018-07-09 08:10:34 -04:00
delete knex . client . config . asyncStackTraces ;
} ) ;
2018-04-25 23:11:24 +02:00
it ( 'should capture stack trace on raw query' , ( ) => {
return knex . raw ( 'select * from some_nonexisten_table' ) . catch ( ( err ) => {
2020-03-11 16:05:03 -04:00
expect ( err . stack . split ( '\n' ) [ 2 ] ) . to . match ( /at Object\.raw \(/ ) ; // the index 2 might need adjustment if the code is refactored
2018-07-09 08:10:34 -04:00
expect ( typeof err . originalStack ) . to . equal ( 'string' ) ;
} ) ;
} ) ;
2018-04-25 23:11:24 +02:00
it ( 'should capture stack trace on schema builder' , ( ) => {
2018-07-09 08:10:34 -04:00
return knex . schema
. renameTable ( 'some_nonexisten_table' , 'whatever' )
. catch ( ( err ) => {
expect ( err . stack . split ( '\n' ) [ 1 ] ) . to . match ( /client\.schemaBuilder/ ) ; // the index 1 might need adjustment if the code is refactored
expect ( typeof err . originalStack ) . to . equal ( 'string' ) ;
} ) ;
} ) ;
} ) ;
2018-04-25 23:11:24 +02:00
2018-05-29 17:42:03 +02:00
it ( 'Overwrite knex.logger functions using config' , ( ) => {
2018-11-19 12:55:50 +01:00
const knexConfig = _ . clone ( knex . client . config ) ;
2018-05-29 17:42:03 +02:00
2018-11-19 12:55:50 +01:00
let callCount = 0 ;
2020-04-19 00:40:23 +02:00
const assertCall = function ( expectedMessage , message ) {
2018-05-29 17:42:03 +02:00
expect ( message ) . to . equal ( expectedMessage ) ;
callCount ++ ;
} ;
knexConfig . log = {
warn : assertCall . bind ( null , 'test' ) ,
error : assertCall . bind ( null , 'test' ) ,
debug : assertCall . bind ( null , 'test' ) ,
2018-07-09 08:10:34 -04:00
deprecate : assertCall . bind (
null ,
'test is deprecated, please use test2'
) ,
2018-05-29 17:42:03 +02:00
} ;
//Sqlite warning message
knexConfig . useNullAsDefault = true ;
2018-11-19 12:55:50 +01:00
const knexDb = new Knex ( knexConfig ) ;
2018-05-29 17:42:03 +02:00
knexDb . client . logger . warn ( 'test' ) ;
knexDb . client . logger . error ( 'test' ) ;
knexDb . client . logger . debug ( 'test' ) ;
knexDb . client . logger . deprecate ( 'test' , 'test2' ) ;
expect ( callCount ) . to . equal ( 4 ) ;
} ) ;
2013-09-12 01:00:44 -04:00
} ) ;
2014-08-21 23:39:12 +02:00
} ;