From e45879a3b4a6d7e265f21103ae044cefb3cee37c Mon Sep 17 00:00:00 2001 From: Paul Oppenheim Date: Thu, 8 Dec 2016 13:14:35 -0800 Subject: [PATCH] knex: add MySqlConnectionConfig, tests (#13161) * knex: add MySqlConnectionConfig, tests * knex: add types for MySqlConnectionConfig queryFormat params --- knex/knex-tests.ts | 13 +++++++++++++ knex/knex.d.ts | 28 +++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index b103562b83..780e41b340 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -36,6 +36,19 @@ var knex = Knex({ } }); +// Mysql configuration +var knex = Knex({ + debug: true, + client: 'mysql', + connection: { + host : '127.0.0.1', + user : 'your_database_user', + password : 'your_database_password', + db : 'myapp_test', + trace: false + } +}); + // Pooling var knex = Knex({ client: 'mysql', diff --git a/knex/knex.d.ts b/knex/knex.d.ts index c1cf4f6cba..822d82a197 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -455,7 +455,7 @@ declare module "knex" { client?: string; dialect?: string; connection?: string|ConnectionConfig|MariaSqlConnectionConfig| - Sqlite3ConnectionConfig|SocketConnectionConfig; + MySqlConnectionConfig|Sqlite3ConnectionConfig|SocketConnectionConfig; pool?: PoolConfig; migrations?: MigratorConfig; acquireConnectionTimeout?: number; @@ -503,6 +503,32 @@ declare module "knex" { rejectUnauthorized?: boolean; } + // Config object for mysql: https://github.com/mysqljs/mysql#connection-options + interface MySqlConnectionConfig { + host?: string; + port?: number; + localAddress?: string; + socketPath?: string; + user?: string; + password?: string; + database?: string; + charset?: string; + timezone?: string; + connectTimeout?: number; + stringifyObjects?: boolean; + insecureAuth?: boolean; + typeCast?: boolean; + queryFormat?: (query: string, values: any) => string; + supportBigNumbers?: boolean; + bigNumberStrings?: boolean; + dateStrings?: boolean; + debug?: boolean; + trace?: boolean; + multipleStatements?: boolean; + flags?: string; + ssl?: string | MariaSslConfiguration; + } + /** Used with SQLite3 adapter */ interface Sqlite3ConnectionConfig { filename: string;