Comparing version 2.1.0 to 2.2.0
@@ -6,2 +6,3 @@ // CockroachDB Client | ||
const QueryCompiler = require('./crdb-querycompiler'); | ||
const ColumnCompiler = require('./crdb-columncompiler'); | ||
const TableCompiler = require('./crdb-tablecompiler'); | ||
@@ -23,2 +24,6 @@ const ViewCompiler = require('./crdb-viewcompiler'); | ||
columnCompiler() { | ||
return new ColumnCompiler(this, ...arguments); | ||
} | ||
tableCompiler() { | ||
@@ -25,0 +30,0 @@ return new TableCompiler(this, ...arguments); |
@@ -127,2 +127,9 @@ // PostgreSQL Column Compiler | ||
} | ||
uuid(options = { primaryKey: false }) { | ||
return ( | ||
'uuid' + | ||
(this.tableCompiler._canBeAddPrimaryKey(options) ? ' primary key' : '') | ||
); | ||
} | ||
} | ||
@@ -137,3 +144,2 @@ | ||
ColumnCompiler_PG.prototype.tinyint = 'smallint'; | ||
ColumnCompiler_PG.prototype.uuid = 'uuid'; | ||
@@ -140,0 +146,0 @@ function jsonColumn(client, jsonb) { |
@@ -47,3 +47,6 @@ /* eslint max-len: 0 */ | ||
: 'create table '; | ||
const columnsSql = ' (' + columns.sql.join(', ') + this._addChecks() + ')'; | ||
const columnsSql = ` (${columns.sql.join(', ')}${ | ||
this.primaryKeys() || '' | ||
}${this._addChecks()})`; | ||
let sql = | ||
@@ -69,2 +72,24 @@ createStatement + | ||
primaryKeys() { | ||
const pks = (this.grouped.alterTable || []).filter( | ||
(k) => k.method === 'primary' | ||
); | ||
if (pks.length > 0 && pks[0].args.length > 0) { | ||
const columns = pks[0].args[0]; | ||
let constraintName = pks[0].args[1] || ''; | ||
let deferrable; | ||
if (isObject(constraintName)) { | ||
({ constraintName, deferrable } = constraintName); | ||
} | ||
deferrable = deferrable ? ` deferrable initially ${deferrable}` : ''; | ||
constraintName = constraintName | ||
? this.formatter.wrap(constraintName) | ||
: this.formatter.wrap(`${this.tableNameRaw}_pkey`); | ||
return `, constraint ${constraintName} primary key (${this.formatter.columnize( | ||
columns | ||
)})${deferrable}`; | ||
} | ||
} | ||
addColumns(columns, prefix, colCompilers) { | ||
@@ -158,7 +183,9 @@ if (prefix === this.alterColumnsPrefix) { | ||
: this.formatter.wrap(`${this.tableNameRaw}_pkey`); | ||
this.pushQuery( | ||
`alter table ${this.tableName()} add constraint ${constraintName} primary key (${this.formatter.columnize( | ||
columns | ||
)})${deferrable}` | ||
); | ||
if (this.method !== 'create' && this.method !== 'createIfNot') { | ||
this.pushQuery( | ||
`alter table ${this.tableName()} add constraint ${constraintName} primary key (${this.formatter.columnize( | ||
columns | ||
)})${deferrable}` | ||
); | ||
} | ||
} | ||
@@ -165,0 +192,0 @@ |
@@ -23,2 +23,11 @@ // SQLite3 | ||
super(config); | ||
if (config.connection && config.connection.filename === undefined) { | ||
this.logger.warn( | ||
'Could not find `connection.filename` in config. Please specify ' + | ||
'the database path and name to avoid errors. ' + | ||
'(see docs https://knexjs.org/guide/#configuration-options)' | ||
); | ||
} | ||
if (config.useNullAsDefault === undefined) { | ||
@@ -28,3 +37,3 @@ this.logger.warn( | ||
'`useNullAsDefault` flag to hide this warning. ' + | ||
'(see docs http://knexjs.org/#Builder-insert).' | ||
'(see docs https://knexjs.org/guide/query-builder.html#insert).' | ||
); | ||
@@ -31,0 +40,0 @@ } |
@@ -79,3 +79,3 @@ // SQLite3 Query Builder & Compiler | ||
'values explicitly or use the `useNullAsDefault` config flag. ' + | ||
'(see docs http://knexjs.org/#Builder-insert).' | ||
'(see docs https://knexjs.org/guide/query-builder.html#insert).' | ||
); | ||
@@ -82,0 +82,0 @@ }); |
@@ -64,3 +64,2 @@ const { KnexTimeoutError } = require('../util/timeout'); | ||
const queryContext = this.builder.queryContext(); | ||
let queryStream; | ||
@@ -72,11 +71,5 @@ const stream = new Transform({ | ||
}, | ||
destroy() { | ||
// For some reason destroy is not available for mssql on Node 14. Might be a problem with tedious: https://github.com/tediousjs/tedious/issues/1139 | ||
if (queryStream && queryStream.destroy) { | ||
queryStream.destroy(new Error('stream destroyed')); | ||
} | ||
}, | ||
}); | ||
stream.on('pipe', (qs) => { | ||
queryStream = qs; | ||
stream.on('close', () => { | ||
this.client.releaseConnection(this.connection); | ||
}); | ||
@@ -83,0 +76,0 @@ |
@@ -72,4 +72,6 @@ const { parse } = require('pg-connection-string'); | ||
for (const [key, value] of parsed.searchParams.entries()) { | ||
const isMySQLLike = ['mysql:', 'mariadb:'].includes(parsed.protocol); | ||
if (isMySQLLike) { | ||
const isNestedConfigSupported = ['mysql:', 'mariadb:', 'mssql:'].includes( | ||
parsed.protocol | ||
); | ||
if (isNestedConfigSupported) { | ||
try { | ||
@@ -76,0 +78,0 @@ connection[key] = JSON.parse(value); |
@@ -280,4 +280,6 @@ // Column Compiler | ||
ColumnCompiler.prototype.bit = ColumnCompiler.prototype.json = 'text'; | ||
ColumnCompiler.prototype.uuid = ({ useBinaryUuid = false } = {}) => | ||
useBinaryUuid ? 'binary(16)' : 'char(36)'; | ||
ColumnCompiler.prototype.uuid = ({ | ||
useBinaryUuid = false, | ||
primaryKey = false, | ||
} = {}) => (useBinaryUuid ? 'binary(16)' : 'char(36)'); | ||
ColumnCompiler.prototype.integer = | ||
@@ -284,0 +286,0 @@ ColumnCompiler.prototype.smallint = |
{ | ||
"name": "knex", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3", | ||
@@ -63,3 +63,3 @@ "main": "knex", | ||
"dependencies": { | ||
"colorette": "2.0.16", | ||
"colorette": "2.0.19", | ||
"commander": "^9.1.0", | ||
@@ -109,3 +109,3 @@ "debug": "4.3.4", | ||
"@tsconfig/recommended": "^1.0.1", | ||
"@types/node": "^17.0.25", | ||
"@types/node": "^18.0.4", | ||
"better-sqlite3": "^7.5.1", | ||
@@ -126,3 +126,3 @@ "chai": "^4.3.6", | ||
"JSONStream": "^1.3.5", | ||
"lint-staged": "^12.3.7", | ||
"lint-staged": "^13.0.0", | ||
"mocha": "^10.0.0", | ||
@@ -147,4 +147,4 @@ "mock-fs": "^5.1.2", | ||
"ts-node": "^10.7.0", | ||
"tsd": "^0.20.0", | ||
"typescript": "4.7.2" | ||
"tsd": "^0.22.0", | ||
"typescript": "4.7.4" | ||
}, | ||
@@ -151,0 +151,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
853456
188
22917
+ Addedcolorette@2.0.19(transitive)
- Removedcolorette@2.0.16(transitive)
Updatedcolorette@2.0.19