From bc85534bc86643f49df83576dc4e43d27c788666 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Tue, 22 Mar 2022 16:00:37 +1100 Subject: [PATCH 1/3] add initial code for taggedExecute methods --- promise.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/promise.js b/promise.js index fc74cc0c3a..1b8d940d58 100644 --- a/promise.js +++ b/promise.js @@ -124,6 +124,13 @@ class PromiseConnection extends EventEmitter { }); } + taggedExecute() { + return (strings, ...keys) => { + const statementQuery = strings.join('?'); + return this.execute(statementQuery, keys).then(result => result[0]) + } + } + end() { return new this.Promise(resolve => { this.connection.end(resolve); @@ -372,6 +379,13 @@ class PromisePool extends EventEmitter { }); } + taggedExecute() { + return (strings, ...keys) => { + const statementQuery = strings.join('?'); + return this.execute(statementQuery, keys).then(result => result[0]); + } + } + end() { const corePool = this.pool; const localErr = new Error(); From b96364e51b69344b0c4a0cc0ccf6b2dde27c6466 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Thu, 24 Mar 2022 11:50:27 +1100 Subject: [PATCH 2/3] cast to a fixed length date type so results are more consistent between server versions --- test/integration/connection/test-execute-bind-date.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/connection/test-execute-bind-date.js b/test/integration/connection/test-execute-bind-date.js index d98e58ce5b..525a4b3290 100644 --- a/test/integration/connection/test-execute-bind-date.js +++ b/test/integration/connection/test-execute-bind-date.js @@ -7,7 +7,7 @@ const assert = require('assert'); const date = new Date(2018, 2, 10, 15, 12, 34, 1234); let rows; -connection.execute('SELECT ? AS result', [date], (err, _rows) => { +connection.execute('SELECT CAST(? AS DATETIME(6)) AS result', [date], (err, _rows) => { if (err) { throw err; } From 5470ff6a53d7c25ef3cfb5ab7da9f049bcdfe073 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Thu, 24 Mar 2022 11:50:57 +1100 Subject: [PATCH 3/3] cleanup --- .../connection/test-connect-after-connection-error.js | 1 - .../connection/test-connect-connection-closed-error.js | 1 - test/integration/connection/test-connect-time-error.js | 1 - 3 files changed, 3 deletions(-) diff --git a/test/integration/connection/test-connect-after-connection-error.js b/test/integration/connection/test-connect-after-connection-error.js index 0eb19c5c54..001a33fbc8 100644 --- a/test/integration/connection/test-connect-after-connection-error.js +++ b/test/integration/connection/test-connect-after-connection-error.js @@ -11,7 +11,6 @@ portfinder.getPort((err, port) => { let serverConnection; server.listen(port); server.on('connection', conn => { - console.log('Here!'); conn.serverHandshake({ serverVersion: '5.6.10', capabilityFlags: 2181036031 diff --git a/test/integration/connection/test-connect-connection-closed-error.js b/test/integration/connection/test-connect-connection-closed-error.js index f6efc3bd6a..84e7749db2 100644 --- a/test/integration/connection/test-connect-connection-closed-error.js +++ b/test/integration/connection/test-connect-connection-closed-error.js @@ -11,7 +11,6 @@ portfinder.getPort((err, port) => { const server = mysql.createServer(); server.listen(port); server.on('connection', conn => { - console.log('Here!'); conn.close(); }); diff --git a/test/integration/connection/test-connect-time-error.js b/test/integration/connection/test-connect-time-error.js index 48fe86dcc5..ed3e64ef4b 100644 --- a/test/integration/connection/test-connect-time-error.js +++ b/test/integration/connection/test-connect-time-error.js @@ -10,7 +10,6 @@ portfinder.getPort((err, port) => { const server = mysql.createServer(); server.listen(port); server.on('connection', conn => { - console.log('Here!'); conn.writeError(new Error(ERROR_TEXT)); conn.close(); });