Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add taggedExecute helper #1539

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ portfinder.getPort((err, port) => {
const server = mysql.createServer();
server.listen(port);
server.on('connection', conn => {
console.log('Here!');
conn.close();
});

Expand Down
1 change: 0 additions & 1 deletion test/integration/connection/test-connect-time-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/connection/test-execute-bind-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down