knex-with-snowflake-latest
Advanced tools
Comparing version 2.4.9 to 2.4.10
@@ -13,2 +13,3 @@ const defer = require('lodash/defer'); | ||
const Client = require('../../client'); | ||
const Bluebird = require('bluebird'); | ||
@@ -175,5 +176,29 @@ class Client_Snowflake extends Client { | ||
// and any other necessary prep work. | ||
_query(connection, obj) { | ||
if (!obj || typeof obj === 'string') obj = { sql: obj }; | ||
return new Bluebird((resolver, rejecter) => { | ||
if (!obj.sql) { | ||
resolver(); | ||
return; | ||
} | ||
const queryOptions = { | ||
sqlText: obj.sql, | ||
binds: obj.bindings, | ||
complete(err, statement, rows) { | ||
if (err) return rejecter(err); | ||
obj.response = { rows, statement }; | ||
resolver(obj); | ||
}, | ||
...obj.options, | ||
}; | ||
connection.execute(queryOptions); | ||
}); | ||
} | ||
// _query(connection, obj) { | ||
// if (!obj || typeof obj === 'string') obj = { sql: obj }; | ||
// return new Bluebird((resolver, rejecter) => { | ||
// if (!obj.sql) throw new Error('The query is empty'); | ||
// return new Promise(function (resolver, rejecter) { | ||
// if (!obj.sql) { | ||
@@ -183,39 +208,15 @@ // resolver(); | ||
// } | ||
// const queryOptions = { | ||
// sqlText: obj.sql, | ||
// binds: obj.bindings, | ||
// complete(err, statement, rows) { | ||
// const queryOptions = Object.assign({ sql: obj.sql }, obj.options); | ||
// connection.query( | ||
// queryOptions, | ||
// obj.bindings, | ||
// function (err, rows, fields) { | ||
// if (err) return rejecter(err); | ||
// obj.response = { rows, statement }; | ||
// obj.response = [rows, fields]; | ||
// resolver(obj); | ||
// }, | ||
// ...obj.options, | ||
// }; | ||
// connection.execute(queryOptions); | ||
// } | ||
// ); | ||
// }); | ||
// } | ||
_query(connection, obj) { | ||
if (!obj || typeof obj === 'string') obj = { sql: obj }; | ||
if (!obj.sql) throw new Error('The query is empty'); | ||
return new Promise(function (resolver, rejecter) { | ||
if (!obj.sql) { | ||
resolver(); | ||
return; | ||
} | ||
const queryOptions = Object.assign({ sql: obj.sql }, obj.options); | ||
connection.query( | ||
queryOptions, | ||
obj.bindings, | ||
function (err, rows, fields) { | ||
if (err) return rejecter(err); | ||
obj.response = [rows, fields]; | ||
resolver(obj); | ||
} | ||
); | ||
}); | ||
} | ||
// Ensures the response is returned in the same format as other clients. | ||
@@ -222,0 +223,0 @@ processResponse(obj, runner) { |
{ | ||
"name": "knex-with-snowflake-latest", | ||
"version": "2.4.9", | ||
"version": "2.4.10", | ||
"description": "A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3", | ||
@@ -5,0 +5,0 @@ "main": "knex", |
869833
23398