knex 0.21.17 → 0.21.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/bin/cli.js +0 -0
- package/lib/dialects/mssql/index.js +2 -0
- package/lib/dialects/sqlite3/schema/ddl.js +2 -2
- package/lib/migrate/Migrator.js +21 -10
- package/lib/util/import-file.js +3 -4
- package/lib/util/is-module-type.js +14 -0
- package/package.json +11 -11
- package/types/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Master (Unreleased)
|
|
2
2
|
|
|
3
|
+
# 0.21.21 - 10 August, 2021
|
|
4
|
+
|
|
5
|
+
### Bug fixes:
|
|
6
|
+
|
|
7
|
+
- CLI: Fix line terminators causing knex migrations to fail
|
|
8
|
+
|
|
9
|
+
# 0.21.20 - 07 August, 2021
|
|
10
|
+
|
|
11
|
+
### Typings:
|
|
12
|
+
|
|
13
|
+
- Added option to mssql connection configuration for trustServerCertificate boolean #4606
|
|
14
|
+
|
|
15
|
+
# 0.21.19 - 02 March, 2021
|
|
16
|
+
|
|
17
|
+
- SQLite: Made the constraint detection case-insensitive #4332
|
|
18
|
+
|
|
19
|
+
# 0.21.18 - 22 February, 2021
|
|
20
|
+
|
|
21
|
+
- CLI: Fix an issue with npm@7 and ESM when type was set to 'module' in package.json #4295
|
|
22
|
+
|
|
3
23
|
# 0.21.17 - 30 January, 2021
|
|
4
24
|
|
|
5
25
|
### Bug fixes:
|
package/bin/cli.js
CHANGED
|
File without changes
|
|
@@ -110,6 +110,8 @@ Object.assign(Client_MSSQL.prototype, {
|
|
|
110
110
|
cfg.options.rowCollectionOnRequestCompletion = false;
|
|
111
111
|
cfg.options.useColumnNames = false;
|
|
112
112
|
cfg.options.appName = cfg.options.appName || 'node-mssql';
|
|
113
|
+
cfg.options.trustServerCertificate =
|
|
114
|
+
cfg.options.trustServerCertificate || false;
|
|
113
115
|
|
|
114
116
|
// tedious always connect via tcp when port is specified
|
|
115
117
|
if (cfg.options.instanceName) delete cfg.options.port;
|
|
@@ -333,8 +333,8 @@ assign(SQLite3_DDL.prototype, {
|
|
|
333
333
|
.map((line) => line.trim())
|
|
334
334
|
.filter((defLine) => {
|
|
335
335
|
if (
|
|
336
|
-
defLine.startsWith('constraint') === false &&
|
|
337
|
-
defLine.includes('foreign key') === false
|
|
336
|
+
defLine.toLowerCase().startsWith('constraint') === false &&
|
|
337
|
+
defLine.toLowerCase().includes('foreign key') === false
|
|
338
338
|
)
|
|
339
339
|
return true;
|
|
340
340
|
|
package/lib/migrate/Migrator.js
CHANGED
|
@@ -80,12 +80,16 @@ class Migrator {
|
|
|
80
80
|
|
|
81
81
|
const transactionForAll =
|
|
82
82
|
!this.config.disableTransactions &&
|
|
83
|
-
!
|
|
84
|
-
|
|
85
|
-
migration
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
!(
|
|
84
|
+
await Promise.all(
|
|
85
|
+
migrations.map(async (migration) => {
|
|
86
|
+
const migrationContents = await this.config.migrationSource.getMigration(
|
|
87
|
+
migration
|
|
88
|
+
);
|
|
89
|
+
return !this._useTransaction(migrationContents);
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
).some((isTransactionUsed) => isTransactionUsed);
|
|
89
93
|
|
|
90
94
|
if (transactionForAll) {
|
|
91
95
|
return this.knex.transaction((trx) => {
|
|
@@ -133,6 +137,16 @@ class Migrator {
|
|
|
133
137
|
migrationToRun = newMigrations[0];
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
return {
|
|
141
|
+
migrationToRun,
|
|
142
|
+
useTransaction:
|
|
143
|
+
!migrationToRun ||
|
|
144
|
+
this._useTransaction(
|
|
145
|
+
this.config.migrationSource.getMigration(migrationToRun)
|
|
146
|
+
),
|
|
147
|
+
};
|
|
148
|
+
})
|
|
149
|
+
.then(({ migrationToRun, useTransaction }) => {
|
|
136
150
|
const migrationsToRun = [];
|
|
137
151
|
if (migrationToRun) {
|
|
138
152
|
migrationsToRun.push(migrationToRun);
|
|
@@ -140,10 +154,7 @@ class Migrator {
|
|
|
140
154
|
|
|
141
155
|
const transactionForAll =
|
|
142
156
|
!this.config.disableTransactions &&
|
|
143
|
-
(!migrationToRun ||
|
|
144
|
-
this._useTransaction(
|
|
145
|
-
this.config.migrationSource.getMigration(migrationToRun)
|
|
146
|
-
));
|
|
157
|
+
(!migrationToRun || useTransaction);
|
|
147
158
|
|
|
148
159
|
if (transactionForAll) {
|
|
149
160
|
return this.knex.transaction((trx) => {
|
package/lib/util/import-file.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const isTypeModule = process.env.npm_package_type === 'module'
|
|
1
|
+
const isModuleType = require('./is-module-type');
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* imports 'mjs', else requires.
|
|
@@ -7,8 +6,8 @@ const isTypeModule = process.env.npm_package_type === 'module'
|
|
|
7
6
|
* @param {string} filepath
|
|
8
7
|
* @todo WARN on version 10 and '--experimental-modules' and '--esm'
|
|
9
8
|
*/
|
|
10
|
-
module.exports = function importFile(filepath) {
|
|
11
|
-
return
|
|
9
|
+
module.exports = async function importFile(filepath) {
|
|
10
|
+
return (await isModuleType(filepath))
|
|
12
11
|
? import(require('url').pathToFileURL(filepath))
|
|
13
12
|
: require(filepath);
|
|
14
13
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { readFile } = require('./fs');
|
|
2
|
+
|
|
3
|
+
module.exports = async function isModuleType(filepath) {
|
|
4
|
+
if (process.env.npm_package_json) {
|
|
5
|
+
// npm >= 7.0.0
|
|
6
|
+
const packageJson = JSON.parse(
|
|
7
|
+
await readFile(process.env.npm_package_json, 'utf-8')
|
|
8
|
+
);
|
|
9
|
+
if (packageJson.type === 'module') {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return process.env.npm_package_type === 'module' || filepath.endsWith('.mjs');
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knex",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.21",
|
|
4
4
|
"description": "A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser",
|
|
5
5
|
"main": "knex.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
]
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@types/node": "^
|
|
87
|
-
"chai": "^4.
|
|
86
|
+
"@types/node": "^16.4.13",
|
|
87
|
+
"chai": "^4.3.4",
|
|
88
88
|
"chai-as-promised": "^7.1.1",
|
|
89
|
-
"chai-subset-in-order": "^2.1
|
|
89
|
+
"chai-subset-in-order": "^2.2.1",
|
|
90
90
|
"cli-testlab": "^2.1.1",
|
|
91
91
|
"coveralls": "^3.1.0",
|
|
92
92
|
"cross-env": "^7.0.3",
|
|
@@ -98,23 +98,23 @@
|
|
|
98
98
|
"jake": "^8.1.1",
|
|
99
99
|
"JSONStream": "^1.3.5",
|
|
100
100
|
"lint-staged": "^10.5.3",
|
|
101
|
-
"mocha": "^8.
|
|
101
|
+
"mocha": "^8.4.0",
|
|
102
102
|
"mock-fs": "^4.13.0",
|
|
103
|
-
"mssql": "^6.3.
|
|
103
|
+
"mssql": "^6.3.2",
|
|
104
104
|
"mysql": "^2.18.1",
|
|
105
|
-
"mysql2": "^2.
|
|
105
|
+
"mysql2": "^2.3.0",
|
|
106
106
|
"nyc": "^15.1.0",
|
|
107
107
|
"oracledb": "^5.1.0",
|
|
108
|
-
"pg": "^8.
|
|
108
|
+
"pg": "^8.7.1",
|
|
109
109
|
"pg-query-stream": "^3.4.2",
|
|
110
110
|
"prettier": "2.2.1",
|
|
111
111
|
"rimraf": "^3.0.2",
|
|
112
|
-
"sinon": "^9.2.
|
|
112
|
+
"sinon": "^9.2.4",
|
|
113
113
|
"sinon-chai": "^3.5.0",
|
|
114
114
|
"source-map-support": "^0.5.19",
|
|
115
|
-
"sqlite3": "^5.0.
|
|
115
|
+
"sqlite3": "^5.0.2",
|
|
116
116
|
"tap-spec": "^5.0.0",
|
|
117
|
-
"tape": "^5.
|
|
117
|
+
"tape": "^5.3.1",
|
|
118
118
|
"toxiproxy-node-client": "^2.0.6",
|
|
119
119
|
"ts-node": "^9.1.1",
|
|
120
120
|
"tsd": "^0.14.0",
|
package/types/index.d.ts
CHANGED