Comparing version 2.2.0 to 2.3.0
@@ -336,10 +336,20 @@ // MSSQL Client | ||
if ( | ||
this.connectionSettings.options && | ||
this.connectionSettings.options.mapBinding | ||
) { | ||
const result = this.connectionSettings.options.mapBinding(binding); | ||
if (result) { | ||
return [result.value, result.type]; | ||
} | ||
} | ||
switch (typeof binding) { | ||
case 'string': | ||
return Driver.TYPES.NVarChar; | ||
return [binding, Driver.TYPES.NVarChar]; | ||
case 'boolean': | ||
return Driver.TYPES.Bit; | ||
return [binding, Driver.TYPES.Bit]; | ||
case 'number': { | ||
if (binding % 1 !== 0) { | ||
return Driver.TYPES.Float; | ||
return [binding, Driver.TYPES.Float]; | ||
} | ||
@@ -354,21 +364,17 @@ | ||
return Driver.TYPES.BigInt; | ||
return [binding, Driver.TYPES.BigInt]; | ||
} | ||
return Driver.TYPES.Int; | ||
return [binding, Driver.TYPES.Int]; | ||
} | ||
default: { | ||
// if (binding === null || typeof binding === 'undefined') { | ||
// return tedious.TYPES.Null; | ||
// } | ||
if (binding instanceof Date) { | ||
return Driver.TYPES.DateTime; | ||
return [binding, Driver.TYPES.DateTime]; | ||
} | ||
if (binding instanceof Buffer) { | ||
return Driver.TYPES.VarBinary; | ||
return [binding, Driver.TYPES.VarBinary]; | ||
} | ||
return Driver.TYPES.NVarChar; | ||
return [binding, Driver.TYPES.NVarChar]; | ||
} | ||
@@ -406,4 +412,4 @@ } | ||
// sets a request input parameter. Detects bigints and decimals and sets type appropriately. | ||
_setReqInput(req, i, binding) { | ||
const tediousType = this._typeForBinding(binding); | ||
_setReqInput(req, i, inputBinding) { | ||
const [binding, tediousType] = this._typeForBinding(inputBinding); | ||
const bindingName = 'p'.concat(i); | ||
@@ -410,0 +416,0 @@ let options; |
@@ -148,2 +148,3 @@ // PostgreSQL Column Compiler | ||
client.config.client === 'cockroachdb' || | ||
client.config.jsonbSupport === true || | ||
parseFloat(client.version) >= 9.2 | ||
@@ -150,0 +151,0 @@ ) { |
@@ -129,2 +129,4 @@ // SQLite3 | ||
case 'update': | ||
callMethod = obj.returning ? 'all' : 'run'; | ||
break; | ||
case 'counter': | ||
@@ -194,12 +196,14 @@ case 'del': | ||
} | ||
// ToDo Implement after https://github.com/microsoft/vscode-node-sqlite3/issues/15 is resolved | ||
this.logger.warn( | ||
'node-sqlite3 does not currently support RETURNING clause' | ||
); | ||
} | ||
return [ctx.lastID]; | ||
} | ||
case 'update': { | ||
if (returning) { | ||
if (response) { | ||
return response; | ||
} | ||
} | ||
return ctx.changes; | ||
} | ||
case 'del': | ||
case 'update': | ||
case 'counter': | ||
@@ -206,0 +210,0 @@ return ctx.changes; |
@@ -152,2 +152,19 @@ // SQLite3 Query Builder & Compiler | ||
// Compiles an `update` query, allowing for a return value. | ||
update() { | ||
const withSQL = this.with(); | ||
const updateData = this._prepUpdate(this.single.update); | ||
const wheres = this.where(); | ||
const { returning } = this.single; | ||
return { | ||
sql: | ||
withSQL + | ||
`update ${this.single.only ? 'only ' : ''}${this.tableName} ` + | ||
`set ${updateData.join(', ')}` + | ||
(wheres ? ` ${wheres}` : '') + | ||
this._returning(returning), | ||
returning, | ||
}; | ||
} | ||
_ignore(columns) { | ||
@@ -154,0 +171,0 @@ if (columns === true) { |
@@ -228,4 +228,3 @@ const transform = require('lodash/transform'); | ||
builder, | ||
client, | ||
bindingHolder | ||
client | ||
); | ||
@@ -232,0 +231,0 @@ } |
{ | ||
"name": "knex", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3", | ||
@@ -108,4 +108,4 @@ "main": "knex", | ||
"@tsconfig/recommended": "^1.0.1", | ||
"@types/node": "^18.0.4", | ||
"better-sqlite3": "^7.5.1", | ||
"@types/node": "^18.7.14", | ||
"better-sqlite3": "^7.6.2", | ||
"chai": "^4.3.6", | ||
@@ -127,9 +127,9 @@ "chai-as-promised": "^7.1.1", | ||
"mocha": "^10.0.0", | ||
"mock-fs": "^5.1.2", | ||
"mock-fs": "^5.1.4", | ||
"mysql": "^2.18.1", | ||
"mysql2": "^2.3.3", | ||
"nyc": "^15.1.0", | ||
"oracledb": "^5.3.0", | ||
"pg": "^8.7.3", | ||
"pg-query-stream": "^4.2.1", | ||
"oracledb": "^5.4.0", | ||
"pg": "^8.8.0", | ||
"pg-query-stream": "^4.2.4", | ||
"prettier": "2.6.2", | ||
@@ -140,10 +140,10 @@ "rimraf": "^3.0.2", | ||
"source-map-support": "^0.5.21", | ||
"sqlite3": "^5.0.4", | ||
"sqlite3": "^5.0.11", | ||
"tap-spec": "^5.0.0", | ||
"tape": "^5.5.3", | ||
"tape": "^5.6.0", | ||
"tedious": "^14.4.0", | ||
"toxiproxy-node-client": "^2.0.6", | ||
"ts-node": "^10.7.0", | ||
"tsd": "^0.22.0", | ||
"typescript": "4.7.4" | ||
"ts-node": "^10.9.1", | ||
"tsd": "^0.23.0", | ||
"typescript": "4.8.2" | ||
}, | ||
@@ -150,0 +150,0 @@ "buildDependencies": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
854789
22946