kysely 0.2.4 → 0.2.5
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/README.md +1 -1
- package/lib/dialect/postgres/postgres-dialect.js +5 -4
- package/lib/index.d.ts +66 -2
- package/lib/index.js +66 -2
- package/lib/kysely.d.ts +15 -14
- package/lib/kysely.js +17 -16
- package/lib/migration/migration.js +2 -2
- package/lib/operation-node/add-column-node.d.ts +6 -19
- package/lib/operation-node/add-column-node.js +5 -14
- package/lib/operation-node/add-constraint-node.d.ts +4 -4
- package/lib/operation-node/add-constraint-node.js +3 -0
- package/lib/operation-node/alias-node.d.ts +4 -2
- package/lib/operation-node/alias-node.js +3 -0
- package/lib/operation-node/alter-column-node.d.ts +6 -1
- package/lib/operation-node/alter-column-node.js +11 -2
- package/lib/operation-node/alter-table-node.d.ts +5 -0
- package/lib/operation-node/alter-table-node.js +9 -0
- package/lib/operation-node/and-node.d.ts +3 -0
- package/lib/operation-node/and-node.js +3 -0
- package/lib/operation-node/check-constraint-node.d.ts +3 -0
- package/lib/operation-node/check-constraint-node.js +3 -0
- package/lib/operation-node/column-definition-node.d.ts +29 -0
- package/lib/operation-node/column-definition-node.js +30 -0
- package/lib/operation-node/column-node.d.ts +3 -0
- package/lib/operation-node/column-node.js +3 -0
- package/lib/operation-node/column-update-node.d.ts +3 -0
- package/lib/operation-node/column-update-node.js +3 -0
- package/lib/operation-node/common-table-expression-node.d.ts +3 -0
- package/lib/operation-node/common-table-expression-node.js +3 -0
- package/lib/operation-node/constraint-node.d.ts +5 -0
- package/lib/operation-node/constraint-node.js +2 -0
- package/lib/operation-node/create-index-node.d.ts +3 -0
- package/lib/operation-node/create-index-node.js +3 -0
- package/lib/operation-node/create-schema-node.d.ts +3 -0
- package/lib/operation-node/create-schema-node.js +3 -0
- package/lib/operation-node/create-table-node.d.ts +9 -9
- package/lib/operation-node/create-table-node.js +23 -5
- package/lib/operation-node/data-type-node.d.ts +3 -0
- package/lib/operation-node/data-type-node.js +3 -0
- package/lib/operation-node/delete-query-node.d.ts +3 -0
- package/lib/operation-node/delete-query-node.js +3 -0
- package/lib/operation-node/drop-column-node.d.ts +3 -0
- package/lib/operation-node/drop-column-node.js +3 -0
- package/lib/operation-node/drop-constraint-node.d.ts +3 -0
- package/lib/operation-node/drop-constraint-node.js +3 -0
- package/lib/operation-node/drop-index-node.d.ts +3 -0
- package/lib/operation-node/drop-index-node.js +3 -0
- package/lib/operation-node/drop-schema-node.d.ts +3 -0
- package/lib/operation-node/drop-schema-node.js +3 -0
- package/lib/operation-node/drop-table-node.d.ts +5 -2
- package/lib/operation-node/drop-table-node.js +3 -0
- package/lib/operation-node/filter-node.d.ts +3 -0
- package/lib/operation-node/filter-node.js +3 -0
- package/lib/operation-node/foreign-key-constraint-node.d.ts +5 -1
- package/lib/operation-node/foreign-key-constraint-node.js +6 -2
- package/lib/operation-node/from-node.d.ts +3 -0
- package/lib/operation-node/from-node.js +3 -0
- package/lib/operation-node/group-by-item-node.d.ts +3 -0
- package/lib/operation-node/group-by-item-node.js +3 -0
- package/lib/operation-node/group-by-node.d.ts +3 -0
- package/lib/operation-node/group-by-node.js +3 -0
- package/lib/operation-node/having-node.d.ts +3 -0
- package/lib/operation-node/having-node.js +3 -0
- package/lib/operation-node/identifier-node.d.ts +3 -0
- package/lib/operation-node/identifier-node.js +3 -0
- package/lib/operation-node/insert-query-node.d.ts +3 -0
- package/lib/operation-node/insert-query-node.js +3 -0
- package/lib/operation-node/join-node.d.ts +3 -0
- package/lib/operation-node/join-node.js +3 -0
- package/lib/operation-node/limit-node.d.ts +3 -0
- package/lib/operation-node/limit-node.js +3 -0
- package/lib/operation-node/list-node.d.ts +3 -0
- package/lib/operation-node/list-node.js +3 -0
- package/lib/operation-node/offset-node.d.ts +3 -0
- package/lib/operation-node/offset-node.js +3 -0
- package/lib/operation-node/on-conflict-node.d.ts +3 -0
- package/lib/operation-node/on-conflict-node.js +3 -0
- package/lib/operation-node/operation-node-transformer.d.ts +2 -0
- package/lib/operation-node/operation-node-transformer.js +12 -6
- package/lib/operation-node/operation-node-visitor.d.ts +2 -0
- package/lib/operation-node/operation-node-visitor.js +12 -1
- package/lib/operation-node/operation-node.d.ts +1 -1
- package/lib/operation-node/operator-node.d.ts +3 -0
- package/lib/operation-node/operator-node.js +3 -0
- package/lib/operation-node/or-node.d.ts +3 -0
- package/lib/operation-node/or-node.js +3 -0
- package/lib/operation-node/order-by-item-node.d.ts +3 -0
- package/lib/operation-node/order-by-item-node.js +3 -0
- package/lib/operation-node/order-by-node.d.ts +3 -0
- package/lib/operation-node/order-by-node.js +3 -0
- package/lib/operation-node/parens-node.d.ts +3 -0
- package/lib/operation-node/parens-node.js +3 -0
- package/lib/operation-node/primary-constraint-node.d.ts +3 -0
- package/lib/operation-node/primary-constraint-node.js +3 -0
- package/lib/operation-node/primitive-value-list-node.d.ts +3 -0
- package/lib/operation-node/primitive-value-list-node.js +3 -0
- package/lib/operation-node/query-node.d.ts +3 -0
- package/lib/operation-node/query-node.js +3 -0
- package/lib/operation-node/raw-node.d.ts +3 -0
- package/lib/operation-node/raw-node.js +3 -0
- package/lib/operation-node/reference-node.d.ts +3 -0
- package/lib/operation-node/reference-node.js +3 -0
- package/lib/operation-node/references-node.d.ts +5 -2
- package/lib/operation-node/references-node.js +5 -2
- package/lib/operation-node/rename-column-node.d.ts +4 -1
- package/lib/operation-node/rename-column-node.js +5 -2
- package/lib/operation-node/returning-node.d.ts +3 -0
- package/lib/operation-node/returning-node.js +3 -0
- package/lib/operation-node/select-all-node.d.ts +3 -0
- package/lib/operation-node/select-all-node.js +3 -0
- package/lib/operation-node/select-query-node.d.ts +3 -0
- package/lib/operation-node/select-query-node.js +3 -0
- package/lib/operation-node/selection-node.d.ts +3 -0
- package/lib/operation-node/selection-node.js +3 -0
- package/lib/operation-node/table-node.d.ts +3 -0
- package/lib/operation-node/table-node.js +3 -0
- package/lib/operation-node/unique-constraint-node.d.ts +3 -0
- package/lib/operation-node/unique-constraint-node.js +3 -0
- package/lib/operation-node/update-query-node.d.ts +3 -0
- package/lib/operation-node/update-query-node.js +3 -0
- package/lib/operation-node/value-list-node.d.ts +3 -0
- package/lib/operation-node/value-list-node.js +3 -0
- package/lib/operation-node/value-node.d.ts +3 -0
- package/lib/operation-node/value-node.js +3 -0
- package/lib/operation-node/where-node.d.ts +3 -0
- package/lib/operation-node/where-node.js +3 -0
- package/lib/operation-node/with-node.d.ts +3 -0
- package/lib/operation-node/with-node.js +3 -0
- package/lib/parser/with-parser.js +1 -1
- package/lib/query-builder/query-builder.d.ts +9 -9
- package/lib/query-builder/query-builder.js +6 -6
- package/lib/query-builder/sub-query-builder.d.ts +1 -1
- package/lib/query-builder/sub-query-builder.js +1 -1
- package/lib/query-compiler/default-query-compiler.d.ts +3 -1
- package/lib/query-compiler/default-query-compiler.js +10 -9
- package/lib/query-compiler/query-compiler.d.ts +2 -1
- package/lib/query-creator.d.ts +2 -2
- package/lib/query-creator.js +1 -1
- package/lib/{util → query-executor}/query-executor.d.ts +0 -0
- package/lib/{util → query-executor}/query-executor.js +1 -1
- package/lib/raw-builder/raw-builder.d.ts +2 -2
- package/lib/raw-builder/raw-builder.js +4 -4
- package/lib/schema/alter-table-builder.d.ts +64 -0
- package/lib/schema/alter-table-builder.js +236 -0
- package/lib/schema/{add-column-builder.d.ts → column-definition-builder.d.ts} +23 -13
- package/lib/schema/column-definition-builder.js +66 -0
- package/lib/schema/create-index-builder.d.ts +2 -2
- package/lib/schema/create-index-builder.js +3 -3
- package/lib/schema/create-schema-builder.d.ts +2 -2
- package/lib/schema/create-schema-builder.js +3 -3
- package/lib/schema/create-table-builder.d.ts +20 -6
- package/lib/schema/create-table-builder.js +27 -8
- package/lib/schema/drop-index-builder.d.ts +2 -2
- package/lib/schema/drop-index-builder.js +3 -3
- package/lib/schema/drop-schema-builder.d.ts +2 -2
- package/lib/schema/drop-schema-builder.js +3 -3
- package/lib/schema/drop-table-builder.d.ts +2 -2
- package/lib/schema/drop-table-builder.js +3 -3
- package/lib/schema/schema.d.ts +17 -3
- package/lib/schema/schema.js +22 -2
- package/lib/transformers/with-schema-transformer.d.ts +2 -0
- package/lib/transformers/with-schema-transformer.js +3 -0
- package/lib/util/object-utils.d.ts +1 -0
- package/lib/util/object-utils.js +13 -1
- package/package.json +2 -2
- package/lib/schema/add-column-builder.js +0 -116
package/README.md
CHANGED
|
@@ -134,7 +134,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
134
134
|
await db.schema
|
|
135
135
|
.createTable('pet')
|
|
136
136
|
.addColumn('id', 'integer', (col) => col.increments().primaryKey())
|
|
137
|
-
.addColumn('name', 'varchar', (col) => col.unique())
|
|
137
|
+
.addColumn('name', 'varchar', (col) => col.notNull().unique())
|
|
138
138
|
.addColumn('owner_id', 'integer', (col) =>
|
|
139
139
|
col.references('person.id').onDelete('cascade')
|
|
140
140
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PostgresDialect = void 0;
|
|
4
|
+
const table_parser_1 = require("../../parser/table-parser");
|
|
4
5
|
const default_query_compiler_1 = require("../../query-compiler/default-query-compiler");
|
|
5
6
|
const postgres_driver_1 = require("./postgres-driver");
|
|
6
7
|
class PostgresDialect {
|
|
@@ -12,13 +13,13 @@ class PostgresDialect {
|
|
|
12
13
|
return new default_query_compiler_1.DefaultQueryCompiler();
|
|
13
14
|
}
|
|
14
15
|
async getTableMetadata(db, tableName) {
|
|
15
|
-
const
|
|
16
|
+
const tableNode = table_parser_1.parseTable(tableName);
|
|
16
17
|
let query = db
|
|
17
18
|
.selectFrom('information_schema.tables')
|
|
18
|
-
.where('table_name', '=',
|
|
19
|
+
.where('table_name', '=', tableNode.table.identifier)
|
|
19
20
|
.select('table_name');
|
|
20
|
-
if (
|
|
21
|
-
query = query.where('table_schema', '=',
|
|
21
|
+
if (tableNode.schema) {
|
|
22
|
+
query = query.where('table_schema', '=', tableNode.schema.identifier);
|
|
22
23
|
}
|
|
23
24
|
const result = await query.executeTakeFirst();
|
|
24
25
|
if (!result) {
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './query-builder/query-builder';
|
|
|
4
4
|
export * from './query-builder/join-builder';
|
|
5
5
|
export * from './query-builder/sub-query-builder';
|
|
6
6
|
export * from './raw-builder/raw-builder';
|
|
7
|
+
export * from './query-executor/query-executor';
|
|
7
8
|
export * from './query-compiler/default-query-compiler';
|
|
8
9
|
export * from './query-compiler/compiled-query';
|
|
9
10
|
export * from './schema/schema';
|
|
@@ -13,14 +14,15 @@ export * from './schema/create-index-builder';
|
|
|
13
14
|
export * from './schema/drop-index-builder';
|
|
14
15
|
export * from './schema/create-schema-builder';
|
|
15
16
|
export * from './schema/drop-schema-builder';
|
|
16
|
-
export * from './schema/
|
|
17
|
+
export * from './schema/column-definition-builder';
|
|
18
|
+
export * from './schema/alter-table-builder';
|
|
17
19
|
export * from './dynamic/dynamic';
|
|
18
20
|
export * from './driver/driver';
|
|
19
21
|
export * from './driver/driver-config';
|
|
20
22
|
export * from './driver/database-connection';
|
|
23
|
+
export * from './driver/database-connection';
|
|
21
24
|
export * from './dialect/postgres/postgres-dialect';
|
|
22
25
|
export * from './dialect/postgres/postgres-driver';
|
|
23
|
-
export * from './driver/database-connection';
|
|
24
26
|
export * from './query-compiler/default-query-compiler';
|
|
25
27
|
export * from './query-compiler/query-compiler';
|
|
26
28
|
export * from './migration/migration';
|
|
@@ -31,3 +33,65 @@ export * from './operation-node/operation-node-transformer';
|
|
|
31
33
|
export * from './operation-node/operation-node-visitor';
|
|
32
34
|
export * from './plugin/plugin';
|
|
33
35
|
export * from './plugin/camel-case/camel-case-plugin';
|
|
36
|
+
export * from './operation-node/operation-node-transformer';
|
|
37
|
+
export * from './operation-node/operation-node-visitor';
|
|
38
|
+
export * from './operation-node/operator-node';
|
|
39
|
+
export * from './operation-node/or-node';
|
|
40
|
+
export * from './operation-node/order-by-item-node';
|
|
41
|
+
export * from './operation-node/order-by-node';
|
|
42
|
+
export * from './operation-node/parens-node';
|
|
43
|
+
export * from './operation-node/primary-constraint-node';
|
|
44
|
+
export * from './operation-node/primitive-value-list-node';
|
|
45
|
+
export * from './operation-node/query-node';
|
|
46
|
+
export * from './operation-node/raw-node';
|
|
47
|
+
export * from './operation-node/reference-node';
|
|
48
|
+
export * from './operation-node/references-node';
|
|
49
|
+
export * from './operation-node/rename-column-node';
|
|
50
|
+
export * from './operation-node/returning-node';
|
|
51
|
+
export * from './operation-node/select-all-node';
|
|
52
|
+
export * from './operation-node/select-query-node';
|
|
53
|
+
export * from './operation-node/selection-node';
|
|
54
|
+
export * from './operation-node/table-node';
|
|
55
|
+
export * from './operation-node/unique-constraint-node';
|
|
56
|
+
export * from './operation-node/update-query-node';
|
|
57
|
+
export * from './operation-node/value-list-node';
|
|
58
|
+
export * from './operation-node/value-node';
|
|
59
|
+
export * from './operation-node/where-node';
|
|
60
|
+
export * from './operation-node/with-node';
|
|
61
|
+
export * from './operation-node/add-column-node';
|
|
62
|
+
export * from './operation-node/add-constraint-node';
|
|
63
|
+
export * from './operation-node/alias-node';
|
|
64
|
+
export * from './operation-node/alter-column-node';
|
|
65
|
+
export * from './operation-node/alter-table-node';
|
|
66
|
+
export * from './operation-node/and-node';
|
|
67
|
+
export * from './operation-node/check-constraint-node';
|
|
68
|
+
export * from './operation-node/column-definition-node';
|
|
69
|
+
export * from './operation-node/column-node';
|
|
70
|
+
export * from './operation-node/column-update-node';
|
|
71
|
+
export * from './operation-node/common-table-expression-node';
|
|
72
|
+
export * from './operation-node/constraint-node';
|
|
73
|
+
export * from './operation-node/create-index-node';
|
|
74
|
+
export * from './operation-node/create-schema-node';
|
|
75
|
+
export * from './operation-node/create-table-node';
|
|
76
|
+
export * from './operation-node/data-type-node';
|
|
77
|
+
export * from './operation-node/delete-query-node';
|
|
78
|
+
export * from './operation-node/drop-column-node';
|
|
79
|
+
export * from './operation-node/drop-constraint-node';
|
|
80
|
+
export * from './operation-node/drop-index-node';
|
|
81
|
+
export * from './operation-node/drop-schema-node';
|
|
82
|
+
export * from './operation-node/drop-table-node';
|
|
83
|
+
export * from './operation-node/filter-node';
|
|
84
|
+
export * from './operation-node/foreign-key-constraint-node';
|
|
85
|
+
export * from './operation-node/from-node';
|
|
86
|
+
export * from './operation-node/group-by-item-node';
|
|
87
|
+
export * from './operation-node/group-by-node';
|
|
88
|
+
export * from './operation-node/having-node';
|
|
89
|
+
export * from './operation-node/identifier-node';
|
|
90
|
+
export * from './operation-node/insert-query-node';
|
|
91
|
+
export * from './operation-node/join-node';
|
|
92
|
+
export * from './operation-node/limit-node';
|
|
93
|
+
export * from './operation-node/list-node';
|
|
94
|
+
export * from './operation-node/offset-node';
|
|
95
|
+
export * from './operation-node//on-conflict-node';
|
|
96
|
+
export * from './operation-node/operation-node';
|
|
97
|
+
export * from './operation-node/operation-node-source';
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ __exportStar(require("./query-builder/query-builder"), exports);
|
|
|
16
16
|
__exportStar(require("./query-builder/join-builder"), exports);
|
|
17
17
|
__exportStar(require("./query-builder/sub-query-builder"), exports);
|
|
18
18
|
__exportStar(require("./raw-builder/raw-builder"), exports);
|
|
19
|
+
__exportStar(require("./query-executor/query-executor"), exports);
|
|
19
20
|
__exportStar(require("./query-compiler/default-query-compiler"), exports);
|
|
20
21
|
__exportStar(require("./query-compiler/compiled-query"), exports);
|
|
21
22
|
__exportStar(require("./schema/schema"), exports);
|
|
@@ -25,14 +26,15 @@ __exportStar(require("./schema/create-index-builder"), exports);
|
|
|
25
26
|
__exportStar(require("./schema/drop-index-builder"), exports);
|
|
26
27
|
__exportStar(require("./schema/create-schema-builder"), exports);
|
|
27
28
|
__exportStar(require("./schema/drop-schema-builder"), exports);
|
|
28
|
-
__exportStar(require("./schema/
|
|
29
|
+
__exportStar(require("./schema/column-definition-builder"), exports);
|
|
30
|
+
__exportStar(require("./schema/alter-table-builder"), exports);
|
|
29
31
|
__exportStar(require("./dynamic/dynamic"), exports);
|
|
30
32
|
__exportStar(require("./driver/driver"), exports);
|
|
31
33
|
__exportStar(require("./driver/driver-config"), exports);
|
|
32
34
|
__exportStar(require("./driver/database-connection"), exports);
|
|
35
|
+
__exportStar(require("./driver/database-connection"), exports);
|
|
33
36
|
__exportStar(require("./dialect/postgres/postgres-dialect"), exports);
|
|
34
37
|
__exportStar(require("./dialect/postgres/postgres-driver"), exports);
|
|
35
|
-
__exportStar(require("./driver/database-connection"), exports);
|
|
36
38
|
__exportStar(require("./query-compiler/default-query-compiler"), exports);
|
|
37
39
|
__exportStar(require("./query-compiler/query-compiler"), exports);
|
|
38
40
|
__exportStar(require("./migration/migration"), exports);
|
|
@@ -43,3 +45,65 @@ __exportStar(require("./operation-node/operation-node-transformer"), exports);
|
|
|
43
45
|
__exportStar(require("./operation-node/operation-node-visitor"), exports);
|
|
44
46
|
__exportStar(require("./plugin/plugin"), exports);
|
|
45
47
|
__exportStar(require("./plugin/camel-case/camel-case-plugin"), exports);
|
|
48
|
+
__exportStar(require("./operation-node/operation-node-transformer"), exports);
|
|
49
|
+
__exportStar(require("./operation-node/operation-node-visitor"), exports);
|
|
50
|
+
__exportStar(require("./operation-node/operator-node"), exports);
|
|
51
|
+
__exportStar(require("./operation-node/or-node"), exports);
|
|
52
|
+
__exportStar(require("./operation-node/order-by-item-node"), exports);
|
|
53
|
+
__exportStar(require("./operation-node/order-by-node"), exports);
|
|
54
|
+
__exportStar(require("./operation-node/parens-node"), exports);
|
|
55
|
+
__exportStar(require("./operation-node/primary-constraint-node"), exports);
|
|
56
|
+
__exportStar(require("./operation-node/primitive-value-list-node"), exports);
|
|
57
|
+
__exportStar(require("./operation-node/query-node"), exports);
|
|
58
|
+
__exportStar(require("./operation-node/raw-node"), exports);
|
|
59
|
+
__exportStar(require("./operation-node/reference-node"), exports);
|
|
60
|
+
__exportStar(require("./operation-node/references-node"), exports);
|
|
61
|
+
__exportStar(require("./operation-node/rename-column-node"), exports);
|
|
62
|
+
__exportStar(require("./operation-node/returning-node"), exports);
|
|
63
|
+
__exportStar(require("./operation-node/select-all-node"), exports);
|
|
64
|
+
__exportStar(require("./operation-node/select-query-node"), exports);
|
|
65
|
+
__exportStar(require("./operation-node/selection-node"), exports);
|
|
66
|
+
__exportStar(require("./operation-node/table-node"), exports);
|
|
67
|
+
__exportStar(require("./operation-node/unique-constraint-node"), exports);
|
|
68
|
+
__exportStar(require("./operation-node/update-query-node"), exports);
|
|
69
|
+
__exportStar(require("./operation-node/value-list-node"), exports);
|
|
70
|
+
__exportStar(require("./operation-node/value-node"), exports);
|
|
71
|
+
__exportStar(require("./operation-node/where-node"), exports);
|
|
72
|
+
__exportStar(require("./operation-node/with-node"), exports);
|
|
73
|
+
__exportStar(require("./operation-node/add-column-node"), exports);
|
|
74
|
+
__exportStar(require("./operation-node/add-constraint-node"), exports);
|
|
75
|
+
__exportStar(require("./operation-node/alias-node"), exports);
|
|
76
|
+
__exportStar(require("./operation-node/alter-column-node"), exports);
|
|
77
|
+
__exportStar(require("./operation-node/alter-table-node"), exports);
|
|
78
|
+
__exportStar(require("./operation-node/and-node"), exports);
|
|
79
|
+
__exportStar(require("./operation-node/check-constraint-node"), exports);
|
|
80
|
+
__exportStar(require("./operation-node/column-definition-node"), exports);
|
|
81
|
+
__exportStar(require("./operation-node/column-node"), exports);
|
|
82
|
+
__exportStar(require("./operation-node/column-update-node"), exports);
|
|
83
|
+
__exportStar(require("./operation-node/common-table-expression-node"), exports);
|
|
84
|
+
__exportStar(require("./operation-node/constraint-node"), exports);
|
|
85
|
+
__exportStar(require("./operation-node/create-index-node"), exports);
|
|
86
|
+
__exportStar(require("./operation-node/create-schema-node"), exports);
|
|
87
|
+
__exportStar(require("./operation-node/create-table-node"), exports);
|
|
88
|
+
__exportStar(require("./operation-node/data-type-node"), exports);
|
|
89
|
+
__exportStar(require("./operation-node/delete-query-node"), exports);
|
|
90
|
+
__exportStar(require("./operation-node/drop-column-node"), exports);
|
|
91
|
+
__exportStar(require("./operation-node/drop-constraint-node"), exports);
|
|
92
|
+
__exportStar(require("./operation-node/drop-index-node"), exports);
|
|
93
|
+
__exportStar(require("./operation-node/drop-schema-node"), exports);
|
|
94
|
+
__exportStar(require("./operation-node/drop-table-node"), exports);
|
|
95
|
+
__exportStar(require("./operation-node/filter-node"), exports);
|
|
96
|
+
__exportStar(require("./operation-node/foreign-key-constraint-node"), exports);
|
|
97
|
+
__exportStar(require("./operation-node/from-node"), exports);
|
|
98
|
+
__exportStar(require("./operation-node/group-by-item-node"), exports);
|
|
99
|
+
__exportStar(require("./operation-node/group-by-node"), exports);
|
|
100
|
+
__exportStar(require("./operation-node/having-node"), exports);
|
|
101
|
+
__exportStar(require("./operation-node/identifier-node"), exports);
|
|
102
|
+
__exportStar(require("./operation-node/insert-query-node"), exports);
|
|
103
|
+
__exportStar(require("./operation-node/join-node"), exports);
|
|
104
|
+
__exportStar(require("./operation-node/limit-node"), exports);
|
|
105
|
+
__exportStar(require("./operation-node/list-node"), exports);
|
|
106
|
+
__exportStar(require("./operation-node/offset-node"), exports);
|
|
107
|
+
__exportStar(require("./operation-node//on-conflict-node"), exports);
|
|
108
|
+
__exportStar(require("./operation-node/operation-node"), exports);
|
|
109
|
+
__exportStar(require("./operation-node/operation-node-source"), exports);
|
package/lib/kysely.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { SchemaModule } from './schema/schema';
|
|
|
5
5
|
import { DynamicModule } from './dynamic/dynamic';
|
|
6
6
|
import { QueryCompiler } from './query-compiler/query-compiler';
|
|
7
7
|
import { MigrationModule } from './migration/migration';
|
|
8
|
-
import { QueryExecutor } from './
|
|
8
|
+
import { QueryExecutor } from './query-executor/query-executor';
|
|
9
9
|
import { QueryCreator } from './query-creator';
|
|
10
10
|
import { KyselyPlugin } from './plugin/plugin';
|
|
11
11
|
/**
|
|
@@ -18,21 +18,22 @@ import { KyselyPlugin } from './plugin/plugin';
|
|
|
18
18
|
* This example assumes your database has tables `person` and `pet`:
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
|
-
* interface
|
|
21
|
+
* interface Person {
|
|
22
22
|
* id: number
|
|
23
23
|
* first_name: string
|
|
24
|
+
* last_name: string
|
|
24
25
|
* }
|
|
25
26
|
*
|
|
26
|
-
* interface
|
|
27
|
+
* interface Pet {
|
|
27
28
|
* id: number
|
|
28
29
|
* owner_id: number
|
|
29
30
|
* name: string
|
|
30
|
-
* species 'cat' | 'dog
|
|
31
|
+
* species 'cat' | 'dog'
|
|
31
32
|
* }
|
|
32
33
|
*
|
|
33
34
|
* interface Database {
|
|
34
|
-
* person:
|
|
35
|
-
* pet:
|
|
35
|
+
* person: Person,
|
|
36
|
+
* pet: Pet
|
|
36
37
|
* }
|
|
37
38
|
*
|
|
38
39
|
* const db = new Kysely<Database>(config)
|
|
@@ -47,17 +48,11 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
47
48
|
constructor(config: KyselyConfig);
|
|
48
49
|
constructor(args: KyselyConstructorArgs);
|
|
49
50
|
/**
|
|
50
|
-
* Returns
|
|
51
|
-
*
|
|
52
|
-
* You can also use `db instanceof Transaction`.
|
|
53
|
-
*/
|
|
54
|
-
get isTransaction(): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Returns the {@link Schema} module for building database schema.
|
|
51
|
+
* Returns the {@link SchemaModule} module for building database schema.
|
|
57
52
|
*/
|
|
58
53
|
get schema(): SchemaModule;
|
|
59
54
|
/**
|
|
60
|
-
* Returns the {@link
|
|
55
|
+
* Returns the {@link MigrationModule} module for managing and running migrations.
|
|
61
56
|
*/
|
|
62
57
|
get migration(): MigrationModule;
|
|
63
58
|
/**
|
|
@@ -122,6 +117,12 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
122
117
|
* You need to call this when you are done using the `Kysely` instance.
|
|
123
118
|
*/
|
|
124
119
|
destroy(): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Returns true if this `Kysely` instance is a transaction.
|
|
122
|
+
*
|
|
123
|
+
* You can also use `db instanceof Transaction`.
|
|
124
|
+
*/
|
|
125
|
+
get isTransaction(): boolean;
|
|
125
126
|
}
|
|
126
127
|
export declare class Transaction<DB> extends Kysely<DB> {
|
|
127
128
|
get isTransaction(): true;
|
package/lib/kysely.js
CHANGED
|
@@ -9,7 +9,7 @@ const object_utils_1 = require("./util/object-utils");
|
|
|
9
9
|
const single_connection_provider_1 = require("./driver/single-connection-provider");
|
|
10
10
|
const driver_internal_1 = require("./driver/driver-internal");
|
|
11
11
|
const migration_1 = require("./migration/migration");
|
|
12
|
-
const query_executor_1 = require("./
|
|
12
|
+
const query_executor_1 = require("./query-executor/query-executor");
|
|
13
13
|
const query_creator_1 = require("./query-creator");
|
|
14
14
|
/**
|
|
15
15
|
* The main Kysely class.
|
|
@@ -21,21 +21,22 @@ const query_creator_1 = require("./query-creator");
|
|
|
21
21
|
* This example assumes your database has tables `person` and `pet`:
|
|
22
22
|
*
|
|
23
23
|
* ```ts
|
|
24
|
-
* interface
|
|
24
|
+
* interface Person {
|
|
25
25
|
* id: number
|
|
26
26
|
* first_name: string
|
|
27
|
+
* last_name: string
|
|
27
28
|
* }
|
|
28
29
|
*
|
|
29
|
-
* interface
|
|
30
|
+
* interface Pet {
|
|
30
31
|
* id: number
|
|
31
32
|
* owner_id: number
|
|
32
33
|
* name: string
|
|
33
|
-
* species 'cat' | 'dog
|
|
34
|
+
* species 'cat' | 'dog'
|
|
34
35
|
* }
|
|
35
36
|
*
|
|
36
37
|
* interface Database {
|
|
37
|
-
* person:
|
|
38
|
-
* pet:
|
|
38
|
+
* person: Person,
|
|
39
|
+
* pet: Pet
|
|
39
40
|
* }
|
|
40
41
|
*
|
|
41
42
|
* const db = new Kysely<Database>(config)
|
|
@@ -76,21 +77,13 @@ class Kysely extends query_creator_1.QueryCreator {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
/**
|
|
79
|
-
* Returns
|
|
80
|
-
*
|
|
81
|
-
* You can also use `db instanceof Transaction`.
|
|
82
|
-
*/
|
|
83
|
-
get isTransaction() {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Returns the {@link Schema} module for building database schema.
|
|
80
|
+
* Returns the {@link SchemaModule} module for building database schema.
|
|
88
81
|
*/
|
|
89
82
|
get schema() {
|
|
90
83
|
return new schema_1.SchemaModule(this.#executor);
|
|
91
84
|
}
|
|
92
85
|
/**
|
|
93
|
-
* Returns the {@link
|
|
86
|
+
* Returns the {@link MigrationModule} module for managing and running migrations.
|
|
94
87
|
*/
|
|
95
88
|
get migration() {
|
|
96
89
|
return new migration_1.MigrationModule(this);
|
|
@@ -185,6 +178,14 @@ class Kysely extends query_creator_1.QueryCreator {
|
|
|
185
178
|
async destroy() {
|
|
186
179
|
await this.#driver[driver_internal_1.INTERNAL_DRIVER_ENSURE_DESTROY]();
|
|
187
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Returns true if this `Kysely` instance is a transaction.
|
|
183
|
+
*
|
|
184
|
+
* You can also use `db instanceof Transaction`.
|
|
185
|
+
*/
|
|
186
|
+
get isTransaction() {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
188
189
|
}
|
|
189
190
|
exports.Kysely = Kysely;
|
|
190
191
|
class Transaction extends Kysely {
|
|
@@ -8,7 +8,7 @@ exports.MIGRATION_TABLE = 'kysely_migration';
|
|
|
8
8
|
exports.MIGRATION_LOCK_TABLE = 'kysely_migration_lock';
|
|
9
9
|
exports.MIGRATION_LOCK_ID = 'migration_lock';
|
|
10
10
|
const MAX_LOCK_WAIT_TIME_MS = 60000;
|
|
11
|
-
const LOCK_ATTEMPT_GAP_MS =
|
|
11
|
+
const LOCK_ATTEMPT_GAP_MS = 500;
|
|
12
12
|
class MigrationModule {
|
|
13
13
|
#db;
|
|
14
14
|
constructor(db) {
|
|
@@ -56,7 +56,7 @@ async function ensureMigrationLockTableExists(db) {
|
|
|
56
56
|
.createTable(exports.MIGRATION_LOCK_TABLE)
|
|
57
57
|
.ifNotExists()
|
|
58
58
|
.addColumn('id', 'varchar', (col) => col.primaryKey())
|
|
59
|
-
.addColumn('is_locked', 'integer', (col) => col.
|
|
59
|
+
.addColumn('is_locked', 'integer', (col) => col.notNull().defaultTo(0))
|
|
60
60
|
.execute();
|
|
61
61
|
}
|
|
62
62
|
catch (error) {
|
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ColumnNode } from './column-node';
|
|
3
|
-
import { DataTypeNode } from './data-type-node';
|
|
1
|
+
import { ColumnDefinitionNode } from './column-definition-node';
|
|
4
2
|
import { OperationNode } from './operation-node';
|
|
5
|
-
import { RawNode } from './raw-node';
|
|
6
|
-
import { ReferencesNode } from './references-node';
|
|
7
|
-
import { ValueNode } from './value-node';
|
|
8
|
-
export declare type AddColumnNodeParams = Omit<Partial<AddColumnNode>, 'kind'>;
|
|
9
|
-
export declare type ColumnDataTypeNode = DataTypeNode | RawNode;
|
|
10
3
|
export interface AddColumnNode extends OperationNode {
|
|
11
4
|
readonly kind: 'AddColumnNode';
|
|
12
|
-
readonly column:
|
|
13
|
-
readonly dataType: ColumnDataTypeNode;
|
|
14
|
-
readonly references?: ReferencesNode;
|
|
15
|
-
readonly isPrimaryKey: boolean;
|
|
16
|
-
readonly isAutoIncrementing: boolean;
|
|
17
|
-
readonly isUnique: boolean;
|
|
18
|
-
readonly isNullable: boolean;
|
|
19
|
-
readonly defaultTo?: ValueNode | RawNode;
|
|
20
|
-
readonly check?: CheckConstraintNode;
|
|
5
|
+
readonly column: ColumnDefinitionNode;
|
|
21
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
22
10
|
export declare const addColumnNode: Readonly<{
|
|
23
11
|
is(node: OperationNode): node is AddColumnNode;
|
|
24
|
-
create(column:
|
|
25
|
-
cloneWith(node: AddColumnNode, params: AddColumnNodeParams): AddColumnNode;
|
|
12
|
+
create(column: ColumnDefinitionNode): AddColumnNode;
|
|
26
13
|
}>;
|
|
@@ -2,26 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addColumnNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
6
8
|
exports.addColumnNode = object_utils_1.freeze({
|
|
7
9
|
is(node) {
|
|
8
10
|
return node.kind === 'AddColumnNode';
|
|
9
11
|
},
|
|
10
|
-
create(column
|
|
12
|
+
create(column) {
|
|
11
13
|
return object_utils_1.freeze({
|
|
12
14
|
kind: 'AddColumnNode',
|
|
13
|
-
column
|
|
14
|
-
dataType,
|
|
15
|
-
isPrimaryKey: false,
|
|
16
|
-
isAutoIncrementing: false,
|
|
17
|
-
isUnique: false,
|
|
18
|
-
isNullable: true,
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
cloneWith(node, params) {
|
|
22
|
-
return object_utils_1.freeze({
|
|
23
|
-
...node,
|
|
24
|
-
...params,
|
|
15
|
+
column,
|
|
25
16
|
});
|
|
26
17
|
},
|
|
27
18
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node';
|
|
2
|
-
import {
|
|
3
|
-
import { UniqueConstraintNode } from './unique-constraint-node';
|
|
4
|
-
import { CheckConstraintNode } from './check-constraint-node';
|
|
5
|
-
export declare type ConstraintNode = PrimaryKeyConstraintNode | UniqueConstraintNode | CheckConstraintNode;
|
|
2
|
+
import { ConstraintNode } from './constraint-node';
|
|
6
3
|
export interface AddConstraintNode extends OperationNode {
|
|
7
4
|
readonly kind: 'AddConstraintNode';
|
|
8
5
|
readonly constraint: ConstraintNode;
|
|
9
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
10
|
export declare const addConstraintNode: Readonly<{
|
|
11
11
|
is(node: OperationNode): node is AddConstraintNode;
|
|
12
12
|
create(constraint: ConstraintNode): AddConstraintNode;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addConstraintNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
exports.addConstraintNode = object_utils_1.freeze({
|
|
6
9
|
is(node) {
|
|
7
10
|
return node.kind === 'AddConstraintNode';
|
|
@@ -5,14 +5,16 @@ import { RawNode } from './raw-node';
|
|
|
5
5
|
import { ReferenceNode } from './reference-node';
|
|
6
6
|
import { SelectQueryNode } from './select-query-node';
|
|
7
7
|
import { TableNode } from './table-node';
|
|
8
|
-
declare type AliasNodeChild = ColumnNode | ReferenceNode | TableNode | RawNode | SelectQueryNode;
|
|
8
|
+
export declare type AliasNodeChild = ColumnNode | ReferenceNode | TableNode | RawNode | SelectQueryNode;
|
|
9
9
|
export interface AliasNode extends OperationNode {
|
|
10
10
|
readonly kind: 'AliasNode';
|
|
11
11
|
readonly node: AliasNodeChild;
|
|
12
12
|
readonly alias: IdentifierNode;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
14
17
|
export declare const aliasNode: Readonly<{
|
|
15
18
|
is(node: OperationNode): node is AliasNode;
|
|
16
19
|
create(node: AliasNodeChild, alias: string): AliasNode;
|
|
17
20
|
}>;
|
|
18
|
-
export {};
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.aliasNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
const identifier_node_1 = require("./identifier-node");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
6
9
|
exports.aliasNode = object_utils_1.freeze({
|
|
7
10
|
is(node) {
|
|
8
11
|
return node.kind === 'AliasNode';
|
|
@@ -3,6 +3,7 @@ import { ColumnNode } from './column-node';
|
|
|
3
3
|
import { DataTypeNode } from './data-type-node';
|
|
4
4
|
import { ValueNode } from './value-node';
|
|
5
5
|
import { RawNode } from './raw-node';
|
|
6
|
+
export declare type AlterColumnNodeParams = Omit<Partial<AlterColumnNode>, 'kind' | 'column'>;
|
|
6
7
|
export interface AlterColumnNode extends OperationNode {
|
|
7
8
|
readonly kind: 'AlterColumnNode';
|
|
8
9
|
readonly column: ColumnNode;
|
|
@@ -13,7 +14,11 @@ export interface AlterColumnNode extends OperationNode {
|
|
|
13
14
|
readonly setNotNull?: true;
|
|
14
15
|
readonly dropNotNull?: true;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare const alterColumnNode: Readonly<{
|
|
17
21
|
is(node: OperationNode): node is AlterColumnNode;
|
|
18
22
|
create(column: string): AlterColumnNode;
|
|
23
|
+
cloneWith(node: AlterColumnNode, params: AlterColumnNodeParams): AlterColumnNode;
|
|
19
24
|
}>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.alterColumnNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
const column_node_1 = require("./column-node");
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
exports.alterColumnNode = object_utils_1.freeze({
|
|
7
10
|
is(node) {
|
|
8
11
|
return node.kind === 'AlterColumnNode';
|
|
9
12
|
},
|
|
@@ -13,4 +16,10 @@ exports.dropColumnNode = object_utils_1.freeze({
|
|
|
13
16
|
column: column_node_1.columnNode.create(column),
|
|
14
17
|
});
|
|
15
18
|
},
|
|
19
|
+
cloneWith(node, params) {
|
|
20
|
+
return object_utils_1.freeze({
|
|
21
|
+
...node,
|
|
22
|
+
...params,
|
|
23
|
+
});
|
|
24
|
+
},
|
|
16
25
|
});
|
|
@@ -7,6 +7,7 @@ import { RenameColumnNode } from './rename-column-node';
|
|
|
7
7
|
import { AlterColumnNode } from './alter-column-node';
|
|
8
8
|
import { AddConstraintNode } from './add-constraint-node';
|
|
9
9
|
import { DropConstraintNode } from './drop-constraint-node';
|
|
10
|
+
export declare type AlterTableNodeParams = Omit<Partial<AlterTableNode>, 'kind' | 'table'>;
|
|
10
11
|
export interface AlterTableNode extends OperationNode {
|
|
11
12
|
readonly kind: 'AlterTableNode';
|
|
12
13
|
readonly table: TableNode;
|
|
@@ -19,7 +20,11 @@ export interface AlterTableNode extends OperationNode {
|
|
|
19
20
|
readonly addConstraint?: AddConstraintNode;
|
|
20
21
|
readonly dropConstraint?: DropConstraintNode;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
22
26
|
export declare const alterTableNode: Readonly<{
|
|
23
27
|
is(node: OperationNode): node is AlterTableNode;
|
|
24
28
|
create(table: string): AlterTableNode;
|
|
29
|
+
cloneWith(node: AlterTableNode, params: AlterTableNodeParams): AlterTableNode;
|
|
25
30
|
}>;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.alterTableNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
const table_node_1 = require("./table-node");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
6
9
|
exports.alterTableNode = object_utils_1.freeze({
|
|
7
10
|
is(node) {
|
|
8
11
|
return node.kind === 'AlterTableNode';
|
|
@@ -13,4 +16,10 @@ exports.alterTableNode = object_utils_1.freeze({
|
|
|
13
16
|
table: table_node_1.tableNode.create(table),
|
|
14
17
|
});
|
|
15
18
|
},
|
|
19
|
+
cloneWith(node, params) {
|
|
20
|
+
return object_utils_1.freeze({
|
|
21
|
+
...node,
|
|
22
|
+
...params,
|
|
23
|
+
});
|
|
24
|
+
},
|
|
16
25
|
});
|
|
@@ -5,6 +5,9 @@ export interface AndNode extends OperationNode {
|
|
|
5
5
|
readonly left: FilterExpressionNode;
|
|
6
6
|
readonly right: FilterExpressionNode;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
8
11
|
export declare const andNode: Readonly<{
|
|
9
12
|
is(node: OperationNode): node is AndNode;
|
|
10
13
|
create(left: FilterExpressionNode, right: FilterExpressionNode): AndNode;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.andNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
exports.andNode = object_utils_1.freeze({
|
|
6
9
|
is(node) {
|
|
7
10
|
return node.kind === 'AndNode';
|
|
@@ -6,6 +6,9 @@ export interface CheckConstraintNode extends OperationNode {
|
|
|
6
6
|
readonly expression: RawNode;
|
|
7
7
|
readonly name?: IdentifierNode;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
9
12
|
export declare const checkConstraintNode: Readonly<{
|
|
10
13
|
is(node: OperationNode): node is CheckConstraintNode;
|
|
11
14
|
create(expressionSql: string, constraintName?: string | undefined): CheckConstraintNode;
|
|
@@ -4,6 +4,9 @@ exports.checkConstraintNode = void 0;
|
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
const raw_node_1 = require("./raw-node");
|
|
6
6
|
const identifier_node_1 = require("./identifier-node");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
7
10
|
exports.checkConstraintNode = object_utils_1.freeze({
|
|
8
11
|
is(node) {
|
|
9
12
|
return node.kind === 'CheckConstraintNode';
|