knex 3.1.0 → 3.2.0
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 +2431 -2380
- package/CONTRIBUTING.md +190 -194
- package/LICENSE +22 -22
- package/README.md +156 -149
- package/UPGRADING.md +245 -245
- package/bin/cli.js +516 -475
- package/bin/knexfile-runtime-error.js +27 -0
- package/bin/utils/cli-config-utils.js +217 -212
- package/bin/utils/constants.js +7 -7
- package/bin/utils/migrationsLister.js +37 -37
- package/knex.js +23 -23
- package/knex.mjs +11 -11
- package/lib/builder-interface-augmenter.js +120 -120
- package/lib/client.js +585 -495
- package/lib/constants.js +61 -61
- package/lib/dialects/better-sqlite3/index.js +101 -77
- package/lib/dialects/cockroachdb/crdb-columncompiler.js +14 -14
- package/lib/dialects/cockroachdb/crdb-querybuilder.js +11 -11
- package/lib/dialects/cockroachdb/crdb-querycompiler.js +122 -122
- package/lib/dialects/cockroachdb/crdb-tablecompiler.js +46 -37
- package/lib/dialects/cockroachdb/crdb-viewcompiler.js +15 -15
- package/lib/dialects/cockroachdb/index.js +86 -86
- package/lib/dialects/index.js +34 -34
- package/lib/dialects/mssql/index.js +498 -500
- package/lib/dialects/mssql/mssql-formatter.js +34 -34
- package/lib/dialects/mssql/query/mssql-querycompiler.js +601 -601
- package/lib/dialects/mssql/schema/mssql-columncompiler.js +185 -185
- package/lib/dialects/mssql/schema/mssql-compiler.js +91 -91
- package/lib/dialects/mssql/schema/mssql-tablecompiler.js +393 -378
- package/lib/dialects/mssql/schema/mssql-viewcompiler.js +55 -55
- package/lib/dialects/mssql/transaction.js +176 -176
- package/lib/dialects/mysql/index.js +317 -206
- package/lib/dialects/mysql/query/mysql-querybuilder.js +14 -14
- package/lib/dialects/mysql/query/mysql-querycompiler.js +292 -292
- package/lib/dialects/mysql/schema/mysql-columncompiler.js +193 -193
- package/lib/dialects/mysql/schema/mysql-compiler.js +60 -60
- package/lib/dialects/mysql/schema/mysql-tablecompiler.js +426 -405
- package/lib/dialects/mysql/schema/mysql-viewbuilder.js +21 -21
- package/lib/dialects/mysql/schema/mysql-viewcompiler.js +15 -15
- package/lib/dialects/mysql/transaction.js +46 -46
- package/lib/dialects/mysql2/index.js +53 -53
- package/lib/dialects/mysql2/transaction.js +44 -44
- package/lib/dialects/oracle/DEAD_CODE.md +5 -5
- package/lib/dialects/oracle/index.js +92 -92
- package/lib/dialects/oracle/query/oracle-querycompiler.js +343 -343
- package/lib/dialects/oracle/schema/internal/incrementUtils.js +22 -22
- package/lib/dialects/oracle/schema/internal/trigger.js +155 -155
- package/lib/dialects/oracle/schema/oracle-columnbuilder.js +17 -17
- package/lib/dialects/oracle/schema/oracle-columncompiler.js +126 -126
- package/lib/dialects/oracle/schema/oracle-compiler.js +124 -124
- package/lib/dialects/oracle/schema/oracle-tablecompiler.js +210 -197
- package/lib/dialects/oracle/utils.js +107 -106
- package/lib/dialects/oracledb/index.js +381 -381
- package/lib/dialects/oracledb/query/oracledb-querycompiler.js +481 -481
- package/lib/dialects/oracledb/schema/oracledb-columncompiler.js +61 -61
- package/lib/dialects/oracledb/schema/oracledb-tablecompiler.js +19 -19
- package/lib/dialects/oracledb/schema/oracledb-viewbuilder.js +13 -13
- package/lib/dialects/oracledb/schema/oracledb-viewcompiler.js +19 -19
- package/lib/dialects/oracledb/transaction.js +98 -98
- package/lib/dialects/oracledb/utils.js +208 -208
- package/lib/dialects/pgnative/index.js +60 -60
- package/lib/dialects/postgres/execution/pg-transaction.js +19 -19
- package/lib/dialects/postgres/index.js +373 -361
- package/lib/dialects/postgres/query/pg-querybuilder.js +43 -43
- package/lib/dialects/postgres/query/pg-querycompiler.js +400 -400
- package/lib/dialects/postgres/schema/pg-columncompiler.js +162 -156
- package/lib/dialects/postgres/schema/pg-compiler.js +138 -138
- package/lib/dialects/postgres/schema/pg-tablecompiler.js +331 -304
- package/lib/dialects/postgres/schema/pg-viewbuilder.js +21 -21
- package/lib/dialects/postgres/schema/pg-viewcompiler.js +35 -35
- package/lib/dialects/redshift/index.js +86 -86
- package/lib/dialects/redshift/query/redshift-querycompiler.js +163 -163
- package/lib/dialects/redshift/schema/redshift-columnbuilder.js +22 -22
- package/lib/dialects/redshift/schema/redshift-columncompiler.js +67 -67
- package/lib/dialects/redshift/schema/redshift-compiler.js +14 -14
- package/lib/dialects/redshift/schema/redshift-tablecompiler.js +134 -122
- package/lib/dialects/redshift/schema/redshift-viewcompiler.js +11 -11
- package/lib/dialects/redshift/transaction.js +32 -32
- package/lib/dialects/sqlite3/execution/sqlite-transaction.js +172 -25
- package/lib/dialects/sqlite3/index.js +263 -250
- package/lib/dialects/sqlite3/query/sqlite-querybuilder.js +33 -33
- package/lib/dialects/sqlite3/query/sqlite-querycompiler.js +341 -334
- package/lib/dialects/sqlite3/schema/ddl.js +380 -400
- package/lib/dialects/sqlite3/schema/internal/compiler.js +327 -327
- package/lib/dialects/sqlite3/schema/internal/parser-combinator.js +161 -161
- package/lib/dialects/sqlite3/schema/internal/parser.js +638 -638
- package/lib/dialects/sqlite3/schema/internal/sqlite-ddl-operations.js +41 -41
- package/lib/dialects/sqlite3/schema/internal/tokenizer.js +38 -38
- package/lib/dialects/sqlite3/schema/internal/utils.js +12 -12
- package/lib/dialects/sqlite3/schema/sqlite-columncompiler.js +50 -50
- package/lib/dialects/sqlite3/schema/sqlite-compiler.js +80 -80
- package/lib/dialects/sqlite3/schema/sqlite-tablecompiler.js +364 -347
- package/lib/dialects/sqlite3/schema/sqlite-viewcompiler.js +40 -40
- package/lib/execution/batch-insert.js +51 -51
- package/lib/execution/internal/delay.js +6 -6
- package/lib/execution/internal/ensure-connection-callback.js +41 -41
- package/lib/execution/internal/query-executioner.js +62 -62
- package/lib/execution/runner.js +325 -325
- package/lib/execution/transaction.js +417 -413
- package/lib/formatter/formatterUtils.js +42 -42
- package/lib/formatter/rawFormatter.js +84 -84
- package/lib/formatter/wrappingFormatter.js +253 -250
- package/lib/formatter.js +25 -25
- package/lib/index.js +3 -3
- package/lib/knex-builder/FunctionHelper.js +80 -80
- package/lib/knex-builder/Knex.js +59 -59
- package/lib/knex-builder/internal/config-resolver.js +57 -57
- package/lib/knex-builder/internal/parse-connection.js +87 -87
- package/lib/knex-builder/make-knex.js +345 -345
- package/lib/logger.js +76 -76
- package/lib/migrations/common/MigrationsLoader.js +36 -36
- package/lib/migrations/migrate/MigrationGenerator.js +84 -84
- package/lib/migrations/migrate/Migrator.js +632 -599
- package/lib/migrations/migrate/migrate-stub.js +17 -17
- package/lib/migrations/migrate/migration-list-resolver.js +33 -33
- package/lib/migrations/migrate/migrator-configuration-merger.js +58 -58
- package/lib/migrations/migrate/sources/fs-migrations.js +74 -74
- package/lib/migrations/migrate/stub/cjs.stub +15 -15
- package/lib/migrations/migrate/stub/coffee.stub +13 -13
- package/lib/migrations/migrate/stub/eg.stub +14 -14
- package/lib/migrations/migrate/stub/js-schema.stub +22 -22
- package/lib/migrations/migrate/stub/js.stub +22 -22
- package/lib/migrations/migrate/stub/knexfile-coffee.stub +34 -34
- package/lib/migrations/migrate/stub/knexfile-eg.stub +43 -43
- package/lib/migrations/migrate/stub/knexfile-js.stub +47 -47
- package/lib/migrations/migrate/stub/knexfile-ls.stub +35 -35
- package/lib/migrations/migrate/stub/knexfile-ts.stub +47 -47
- package/lib/migrations/migrate/stub/ls.stub +14 -14
- package/lib/migrations/migrate/stub/mjs.stub +23 -23
- package/lib/migrations/migrate/stub/ts-schema.stub +21 -21
- package/lib/migrations/migrate/stub/ts.stub +21 -21
- package/lib/migrations/migrate/table-creator.js +77 -77
- package/lib/migrations/migrate/table-resolver.js +27 -27
- package/lib/migrations/seed/Seeder.js +137 -137
- package/lib/migrations/seed/seed-stub.js +13 -13
- package/lib/migrations/seed/seeder-configuration-merger.js +60 -60
- package/lib/migrations/seed/sources/fs-seeds.js +65 -65
- package/lib/migrations/seed/stub/coffee.stub +9 -9
- package/lib/migrations/seed/stub/eg.stub +11 -11
- package/lib/migrations/seed/stub/js.stub +13 -13
- package/lib/migrations/seed/stub/ls.stub +11 -11
- package/lib/migrations/seed/stub/mjs.stub +12 -12
- package/lib/migrations/seed/stub/ts.stub +13 -13
- package/lib/migrations/util/fs.js +86 -86
- package/lib/migrations/util/import-file.js +12 -12
- package/lib/migrations/util/is-module-type.js +9 -9
- package/lib/migrations/util/template.js +52 -52
- package/lib/migrations/util/timestamp.js +14 -14
- package/lib/query/analytic.js +52 -52
- package/lib/query/constants.js +15 -15
- package/lib/query/joinclause.js +270 -270
- package/lib/query/method-constants.js +136 -136
- package/lib/query/querybuilder.js +1793 -1793
- package/lib/query/querycompiler.js +1634 -1591
- package/lib/raw.js +139 -139
- package/lib/ref.js +39 -39
- package/lib/schema/builder.js +115 -115
- package/lib/schema/columnbuilder.js +146 -146
- package/lib/schema/columncompiler.js +307 -307
- package/lib/schema/compiler.js +187 -187
- package/lib/schema/internal/helpers.js +55 -55
- package/lib/schema/tablebuilder.js +379 -376
- package/lib/schema/tablecompiler.js +450 -439
- package/lib/schema/viewbuilder.js +92 -92
- package/lib/schema/viewcompiler.js +138 -138
- package/lib/util/finally-mixin.js +13 -13
- package/lib/util/helpers.js +95 -95
- package/lib/util/is.js +32 -32
- package/lib/util/nanoid.js +40 -40
- package/lib/util/noop.js +1 -1
- package/lib/util/save-async-stack.js +14 -14
- package/lib/util/security.js +32 -26
- package/lib/util/string.js +190 -190
- package/lib/util/timeout.js +29 -29
- package/package.json +285 -267
- package/scripts/act-testing/act.sh +19 -0
- package/scripts/act-testing/merged-no-label.json +11 -0
- package/scripts/act-testing/merged-patch-labeled.json +12 -0
- package/scripts/act-testing/merged-skip-labeled.json +12 -0
- package/scripts/act-testing/not-merged-patch-labeled.json +12 -0
- package/scripts/build-for-release.sh +122 -0
- package/scripts/build.js +125 -125
- package/scripts/clean.js +31 -31
- package/scripts/docker-compose.yml +150 -152
- package/scripts/format-changelog.js +55 -0
- package/scripts/next-release-howto.md +24 -24
- package/scripts/oracledb-install-driver-libs.sh +82 -82
- package/scripts/release.sh +36 -36
- package/scripts/runkit-example.js +35 -35
- package/scripts/stress-test/README.txt +18 -18
- package/scripts/stress-test/docker-compose.yml +55 -57
- package/scripts/stress-test/knex-stress-test.js +212 -212
- package/scripts/stress-test/mysql2-random-hanging-every-now-and-then.js +149 -149
- package/scripts/stress-test/mysql2-sudden-exit-without-error.js +101 -101
- package/scripts/stress-test/reconnect-test-mysql-based-drivers.js +188 -188
- package/types/index.d.ts +3321 -3275
- package/types/result.d.ts +27 -27
- package/types/tables.d.ts +4 -4
- package/scripts/update_gitignore_for_tsc_output.js +0 -90
package/types/result.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// This empty interface serves as a placeholder which userland code can augment to
|
|
2
|
-
// override result types.
|
|
3
|
-
//
|
|
4
|
-
// Currently only available result type which is overridable is Count, which defaults to
|
|
5
|
-
// number | string;
|
|
6
|
-
//
|
|
7
|
-
// Following example in userland code will alter this to be just number:
|
|
8
|
-
//
|
|
9
|
-
// declare module "knex/types/result" {
|
|
10
|
-
// interface Registry {
|
|
11
|
-
// Count: number;
|
|
12
|
-
// }
|
|
13
|
-
// }
|
|
14
|
-
//
|
|
15
|
-
// Prior discussion: https://github.com/tgriesser/knex/issues/3247
|
|
16
|
-
export interface Registry {
|
|
17
|
-
// We can't actually have default types here
|
|
18
|
-
// because typescript's augmentation will not permit
|
|
19
|
-
// overriding the type of a property already present.
|
|
20
|
-
//
|
|
21
|
-
// But the effective defaults are documented below:
|
|
22
|
-
//
|
|
23
|
-
// Count: number | string;
|
|
24
|
-
//
|
|
25
|
-
// Refer to Knex.Lookup type operator to see how the defaults
|
|
26
|
-
// are actually specified.
|
|
27
|
-
}
|
|
1
|
+
// This empty interface serves as a placeholder which userland code can augment to
|
|
2
|
+
// override result types.
|
|
3
|
+
//
|
|
4
|
+
// Currently only available result type which is overridable is Count, which defaults to
|
|
5
|
+
// number | string;
|
|
6
|
+
//
|
|
7
|
+
// Following example in userland code will alter this to be just number:
|
|
8
|
+
//
|
|
9
|
+
// declare module "knex/types/result" {
|
|
10
|
+
// interface Registry {
|
|
11
|
+
// Count: number;
|
|
12
|
+
// }
|
|
13
|
+
// }
|
|
14
|
+
//
|
|
15
|
+
// Prior discussion: https://github.com/tgriesser/knex/issues/3247
|
|
16
|
+
export interface Registry {
|
|
17
|
+
// We can't actually have default types here
|
|
18
|
+
// because typescript's augmentation will not permit
|
|
19
|
+
// overriding the type of a property already present.
|
|
20
|
+
//
|
|
21
|
+
// But the effective defaults are documented below:
|
|
22
|
+
//
|
|
23
|
+
// Count: number | string;
|
|
24
|
+
//
|
|
25
|
+
// Refer to Knex.Lookup type operator to see how the defaults
|
|
26
|
+
// are actually specified.
|
|
27
|
+
}
|
package/types/tables.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Placeholder interface for Table -> Record mapping
|
|
2
|
-
// Allows to define the mapping of tables and interfaces in one place
|
|
3
|
-
// and to have correct types when using `knex.from('table')`
|
|
4
|
-
export interface Tables {}
|
|
1
|
+
// Placeholder interface for Table -> Record mapping
|
|
2
|
+
// Allows to define the mapping of tables and interfaces in one place
|
|
3
|
+
// and to have correct types when using `knex.from('table')`
|
|
4
|
+
export interface Tables {}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
|
|
6
|
-
// Directory constants
|
|
7
|
-
const scriptDirectory = __dirname;
|
|
8
|
-
const repoDirectory = path.join(scriptDirectory, '..');
|
|
9
|
-
const libDirectory = path.join(repoDirectory, 'lib');
|
|
10
|
-
|
|
11
|
-
const helpText = `
|
|
12
|
-
Helper script to update lib/.gitignore for all .js files from .ts files.
|
|
13
|
-
|
|
14
|
-
update_gitignore_for_tsc_output.js COMMAND
|
|
15
|
-
|
|
16
|
-
COMMAND:
|
|
17
|
-
run: Update lib/.gitignore file.
|
|
18
|
-
help: Print this menu.
|
|
19
|
-
|
|
20
|
-
NOTES FOR USAGE:
|
|
21
|
-
1. This script is tested to work on Ubuntu 18.04 LTS.
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
const gitignoreHeader = `# DO NOT EDIT, GENERATED BY: scripts/update_gitignore_for_tsc_output.js
|
|
25
|
-
|
|
26
|
-
# Do not include tsc generated type definitions
|
|
27
|
-
**/*.d.ts
|
|
28
|
-
|
|
29
|
-
# Do not include tsc source maps
|
|
30
|
-
**/*.js.map
|
|
31
|
-
|
|
32
|
-
# Do not include .js files from .ts files
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
function main(cliCommand) {
|
|
36
|
-
if (cliCommand === 'run') {
|
|
37
|
-
console.log('Generating lib/.gitignore ...');
|
|
38
|
-
|
|
39
|
-
// Find all .ts files in lib/
|
|
40
|
-
const directoriesToProcess = [libDirectory];
|
|
41
|
-
const tsFiles = [];
|
|
42
|
-
while (directoriesToProcess.length > 0) {
|
|
43
|
-
const directory = directoriesToProcess.pop();
|
|
44
|
-
if (!fs.existsSync(directory)) {
|
|
45
|
-
throw new Error("Directory doesn't exist:", directory);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const files = fs.readdirSync(directory);
|
|
49
|
-
files.forEach((file) => {
|
|
50
|
-
const filename = path.join(directory, file);
|
|
51
|
-
const stat = fs.lstatSync(filename);
|
|
52
|
-
if (stat.isDirectory()) {
|
|
53
|
-
directoriesToProcess.push(filename);
|
|
54
|
-
} else if (filename.endsWith('.ts') && !filename.endsWith('.d.ts')) {
|
|
55
|
-
tsFiles.push(filename);
|
|
56
|
-
console.log('Found .ts file:', filename);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Get paths of .js files to ignore
|
|
62
|
-
const jsFilesToIgnore = tsFiles.map((filepath) => {
|
|
63
|
-
// Cuts off `${libDirectory}/`
|
|
64
|
-
const relativeTsPath = filepath.slice(libDirectory.length + 1);
|
|
65
|
-
// Swaps .ts for .js file ending
|
|
66
|
-
const relativeJsPath =
|
|
67
|
-
relativeTsPath.slice(0, relativeTsPath.length - 3) + '.js';
|
|
68
|
-
// Always use POSIX-style path separators - .gitignore requires it
|
|
69
|
-
return relativeJsPath.split(path.sep).join(path.posix.sep);
|
|
70
|
-
});
|
|
71
|
-
const jsFilesToIgnoreString = jsFilesToIgnore.join('\n');
|
|
72
|
-
const libGitignorePath = path.join(libDirectory, '.gitignore');
|
|
73
|
-
fs.writeFileSync(
|
|
74
|
-
libGitignorePath,
|
|
75
|
-
gitignoreHeader + jsFilesToIgnoreString + '\n'
|
|
76
|
-
);
|
|
77
|
-
console.log('DONE');
|
|
78
|
-
} else if (['help', '--help', '-h', undefined].includes(cliCommand)) {
|
|
79
|
-
console.log(helpText);
|
|
80
|
-
} else {
|
|
81
|
-
console.log(`Unsupported command: ${cliCommand}`);
|
|
82
|
-
console.log("Try running with 'help' to see supported commands.");
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Main script logic
|
|
88
|
-
const cliCommand = process.argv[2];
|
|
89
|
-
// Start the bash app's main function
|
|
90
|
-
main(cliCommand);
|