From a3633084f4b29a36e47c434a5246124852d7f667 Mon Sep 17 00:00:00 2001 From: Jonny Stoten Date: Mon, 19 Oct 2015 18:01:55 +0100 Subject: [PATCH 1/3] Add some extras to knex that we've needed --- knex/knex.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 82c26cfec6..d2afc4aa82 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -135,6 +135,8 @@ declare module "knex" { transacting(trx: Transaction): QueryBuilder; connection(connection: any): QueryBuilder; + + clone(): QueryBuilder; } interface As { @@ -394,6 +396,7 @@ declare module "knex" { } interface Config { + debug?: boolean; client?: string; dialect?: string; connection: string|ConnectionConfig| @@ -427,7 +430,9 @@ declare module "knex" { interface PoolConfig { name?: string; create?: Function; + afterCreate?: Function; destroy?: Function; + beforeDestroy?: Function; min?: number; max?: number; refreshIdle?: boolean; From 0fe43e1a8355262e09c72829d5b68bb64223fb16 Mon Sep 17 00:00:00 2001 From: Jonny Stoten Date: Mon, 19 Oct 2015 20:49:57 +0100 Subject: [PATCH 2/3] Add test code for additions --- knex/knex-test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/knex/knex-test.ts b/knex/knex-test.ts index 081f98867d..5e5c64428d 100644 --- a/knex/knex-test.ts +++ b/knex/knex-test.ts @@ -12,6 +12,7 @@ var knex = Knex({ }); var knex = Knex({ + debug: true, client: 'mysql', connection: { socketPath : '/path/to/socket.sock', @@ -32,7 +33,13 @@ var knex = Knex({ }, pool: { min: 0, - max: 7 + max: 7, + afterCreate: (connection, callback) => { + return callback(null, connection); + }, + beforeDestroy: (connection, callback) => { + return callback(null, connection); + } } }); From 2222f9504b21ab47092151d792560ca92369c479 Mon Sep 17 00:00:00 2001 From: Jonny Stoten Date: Mon, 19 Oct 2015 21:02:09 +0100 Subject: [PATCH 3/3] Fix tests! --- knex/knex-test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/knex/knex-test.ts b/knex/knex-test.ts index 5e5c64428d..1d468b2605 100644 --- a/knex/knex-test.ts +++ b/knex/knex-test.ts @@ -34,10 +34,10 @@ var knex = Knex({ pool: { min: 0, max: 7, - afterCreate: (connection, callback) => { + afterCreate: (connection: any, callback: Function) => { return callback(null, connection); }, - beforeDestroy: (connection, callback) => { + beforeDestroy: (connection: any, callback: Function) => { return callback(null, connection); } }