kysely 0.9.0 → 0.9.1
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/dist/cjs/operation-node/create-schema-node.d.ts +1 -1
- package/dist/cjs/operation-node/create-schema-node.js +2 -2
- package/dist/cjs/operation-node/create-table-node.d.ts +1 -5
- package/dist/cjs/operation-node/create-table-node.js +1 -31
- package/dist/cjs/operation-node/operation-node-source.d.ts +1 -1
- package/dist/cjs/operation-node/operation-node-transformer.js +2 -1
- package/dist/cjs/query-compiler/default-query-compiler.js +1 -1
- package/dist/cjs/schema/create-schema-builder.js +1 -1
- package/dist/cjs/schema/create-table-builder.js +7 -4
- package/dist/esm/operation-node/create-schema-node.d.ts +1 -1
- package/dist/esm/operation-node/create-schema-node.js +2 -2
- package/dist/esm/operation-node/create-table-node.d.ts +1 -5
- package/dist/esm/operation-node/create-table-node.js +1 -31
- package/dist/esm/operation-node/operation-node-source.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-transformer.js +2 -1
- package/dist/esm/query-compiler/default-query-compiler.js +1 -1
- package/dist/esm/schema/create-schema-builder.js +1 -1
- package/dist/esm/schema/create-table-builder.js +7 -4
- package/package.json +1 -1
|
@@ -13,5 +13,5 @@ export interface CreateSchemaNode extends OperationNode {
|
|
|
13
13
|
export declare const CreateSchemaNode: Readonly<{
|
|
14
14
|
is(node: OperationNode): node is CreateSchemaNode;
|
|
15
15
|
create(schema: string, params?: CreateSchemaNodeParams | undefined): CreateSchemaNode;
|
|
16
|
-
|
|
16
|
+
cloneWith(createSchema: CreateSchemaNode, params: CreateSchemaNodeParams): CreateSchemaNode;
|
|
17
17
|
}>;
|
|
@@ -17,10 +17,10 @@ exports.CreateSchemaNode = (0, object_utils_js_1.freeze)({
|
|
|
17
17
|
...params,
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
cloneWith(createSchema, params) {
|
|
21
21
|
return (0, object_utils_js_1.freeze)({
|
|
22
22
|
...createSchema,
|
|
23
|
-
|
|
23
|
+
...params,
|
|
24
24
|
});
|
|
25
25
|
},
|
|
26
26
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node.js';
|
|
2
2
|
import { TableNode } from './table-node.js';
|
|
3
|
-
import { ForeignKeyConstraintNode } from './foreign-key-constraint-node.js';
|
|
4
3
|
import { ConstraintNode } from './constraint-node.js';
|
|
5
4
|
import { ColumnDefinitionNode } from './column-definition-node.js';
|
|
6
5
|
export declare type CreateTableNodeModifier = 'IfNotExists';
|
|
@@ -19,8 +18,5 @@ export declare const CreateTableNode: Readonly<{
|
|
|
19
18
|
create(table: TableNode): CreateTableNode;
|
|
20
19
|
cloneWithColumn(createTable: CreateTableNode, column: ColumnDefinitionNode): CreateTableNode;
|
|
21
20
|
cloneWithModifier(createTable: CreateTableNode, modifier: CreateTableNodeModifier): CreateTableNode;
|
|
22
|
-
|
|
23
|
-
cloneWithUniqueConstraint(createTable: CreateTableNode, constraintName: string, columns: string[]): CreateTableNode;
|
|
24
|
-
cloneWithCheckConstraint(createTable: CreateTableNode, constraintName: string, sql: string): CreateTableNode;
|
|
25
|
-
cloneWithForeignKeyConstraint(createTable: CreateTableNode, constraint: ForeignKeyConstraintNode): CreateTableNode;
|
|
21
|
+
cloneWithConstraint(createTable: CreateTableNode, constraint: ConstraintNode): CreateTableNode;
|
|
26
22
|
}>;
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CreateTableNode = void 0;
|
|
4
4
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
5
|
-
const check_constraint_node_js_1 = require("./check-constraint-node.js");
|
|
6
|
-
const primary_constraint_node_js_1 = require("./primary-constraint-node.js");
|
|
7
|
-
const unique_constraint_node_js_1 = require("./unique-constraint-node.js");
|
|
8
5
|
/**
|
|
9
6
|
* @internal
|
|
10
7
|
*/
|
|
@@ -31,34 +28,7 @@ exports.CreateTableNode = (0, object_utils_js_1.freeze)({
|
|
|
31
28
|
modifier,
|
|
32
29
|
});
|
|
33
30
|
},
|
|
34
|
-
|
|
35
|
-
const constraint = primary_constraint_node_js_1.PrimaryConstraintNode.create(columns, constraintName);
|
|
36
|
-
return (0, object_utils_js_1.freeze)({
|
|
37
|
-
...createTable,
|
|
38
|
-
constraints: createTable.constraints
|
|
39
|
-
? (0, object_utils_js_1.freeze)([...createTable.constraints, constraint])
|
|
40
|
-
: (0, object_utils_js_1.freeze)([constraint]),
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
cloneWithUniqueConstraint(createTable, constraintName, columns) {
|
|
44
|
-
const constraint = unique_constraint_node_js_1.UniqueConstraintNode.create(columns, constraintName);
|
|
45
|
-
return (0, object_utils_js_1.freeze)({
|
|
46
|
-
...createTable,
|
|
47
|
-
constraints: createTable.constraints
|
|
48
|
-
? (0, object_utils_js_1.freeze)([...createTable.constraints, constraint])
|
|
49
|
-
: (0, object_utils_js_1.freeze)([constraint]),
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
cloneWithCheckConstraint(createTable, constraintName, sql) {
|
|
53
|
-
const constraint = check_constraint_node_js_1.CheckConstraintNode.create(sql, constraintName);
|
|
54
|
-
return (0, object_utils_js_1.freeze)({
|
|
55
|
-
...createTable,
|
|
56
|
-
constraints: createTable.constraints
|
|
57
|
-
? (0, object_utils_js_1.freeze)([...createTable.constraints, constraint])
|
|
58
|
-
: (0, object_utils_js_1.freeze)([constraint]),
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
cloneWithForeignKeyConstraint(createTable, constraint) {
|
|
31
|
+
cloneWithConstraint(createTable, constraint) {
|
|
62
32
|
return (0, object_utils_js_1.freeze)({
|
|
63
33
|
...createTable,
|
|
64
34
|
constraints: createTable.constraints
|
|
@@ -2,4 +2,4 @@ import { OperationNode } from './operation-node.js';
|
|
|
2
2
|
export interface OperationNodeSource {
|
|
3
3
|
toOperationNode(): OperationNode;
|
|
4
4
|
}
|
|
5
|
-
export declare function isOperationNodeSource(obj:
|
|
5
|
+
export declare function isOperationNodeSource(obj: unknown): obj is OperationNodeSource;
|
|
@@ -456,11 +456,12 @@ class OperationNodeTransformer {
|
|
|
456
456
|
kind: 'AlterTableNode',
|
|
457
457
|
table: this.transformNode(node.table),
|
|
458
458
|
renameTo: this.transformNode(node.renameTo),
|
|
459
|
-
renameColumn: this.transformNode(node.renameColumn),
|
|
460
459
|
setSchema: this.transformNode(node.setSchema),
|
|
460
|
+
renameColumn: this.transformNode(node.renameColumn),
|
|
461
461
|
addColumn: this.transformNode(node.addColumn),
|
|
462
462
|
dropColumn: this.transformNode(node.dropColumn),
|
|
463
463
|
alterColumn: this.transformNode(node.alterColumn),
|
|
464
|
+
modifyColumn: this.transformNode(node.modifyColumn),
|
|
464
465
|
addConstraint: this.transformNode(node.addConstraint),
|
|
465
466
|
dropConstraint: this.transformNode(node.dropConstraint),
|
|
466
467
|
};
|
|
@@ -12,7 +12,7 @@ class CreateSchemaBuilder {
|
|
|
12
12
|
ifNotExists() {
|
|
13
13
|
return new CreateSchemaBuilder({
|
|
14
14
|
...this.#props,
|
|
15
|
-
createSchemaNode: create_schema_node_js_1.CreateSchemaNode.
|
|
15
|
+
createSchemaNode: create_schema_node_js_1.CreateSchemaNode.cloneWith(this.#props.createSchemaNode, { modifier: 'IfNotExists' }),
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
toOperationNode() {
|
|
@@ -11,6 +11,9 @@ const column_node_js_1 = require("../operation-node/column-node.js");
|
|
|
11
11
|
const table_node_js_1 = require("../operation-node/table-node.js");
|
|
12
12
|
const foreign_key_constraint_builder_js_1 = require("./foreign-key-constraint-builder.js");
|
|
13
13
|
const data_type_parser_js_1 = require("../parser/data-type-parser.js");
|
|
14
|
+
const primary_constraint_node_js_1 = require("../operation-node/primary-constraint-node.js");
|
|
15
|
+
const unique_constraint_node_js_1 = require("../operation-node/unique-constraint-node.js");
|
|
16
|
+
const check_constraint_node_js_1 = require("../operation-node/check-constraint-node.js");
|
|
14
17
|
/**
|
|
15
18
|
* This builder can be used to create a `create table` query.
|
|
16
19
|
*/
|
|
@@ -95,7 +98,7 @@ class CreateTableBuilder {
|
|
|
95
98
|
addPrimaryKeyConstraint(constraintName, columns) {
|
|
96
99
|
return new CreateTableBuilder({
|
|
97
100
|
...this.#props,
|
|
98
|
-
createTableNode: create_table_node_js_1.CreateTableNode.
|
|
101
|
+
createTableNode: create_table_node_js_1.CreateTableNode.cloneWithConstraint(this.#props.createTableNode, primary_constraint_node_js_1.PrimaryConstraintNode.create(columns, constraintName)),
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
/**
|
|
@@ -112,7 +115,7 @@ class CreateTableBuilder {
|
|
|
112
115
|
addUniqueConstraint(constraintName, columns) {
|
|
113
116
|
return new CreateTableBuilder({
|
|
114
117
|
...this.#props,
|
|
115
|
-
createTableNode: create_table_node_js_1.CreateTableNode.
|
|
118
|
+
createTableNode: create_table_node_js_1.CreateTableNode.cloneWithConstraint(this.#props.createTableNode, unique_constraint_node_js_1.UniqueConstraintNode.create(columns, constraintName)),
|
|
116
119
|
});
|
|
117
120
|
}
|
|
118
121
|
/**
|
|
@@ -129,7 +132,7 @@ class CreateTableBuilder {
|
|
|
129
132
|
addCheckConstraint(constraintName, checkExpression) {
|
|
130
133
|
return new CreateTableBuilder({
|
|
131
134
|
...this.#props,
|
|
132
|
-
createTableNode: create_table_node_js_1.CreateTableNode.
|
|
135
|
+
createTableNode: create_table_node_js_1.CreateTableNode.cloneWithConstraint(this.#props.createTableNode, check_constraint_node_js_1.CheckConstraintNode.create(checkExpression, constraintName)),
|
|
133
136
|
});
|
|
134
137
|
}
|
|
135
138
|
/**
|
|
@@ -163,7 +166,7 @@ class CreateTableBuilder {
|
|
|
163
166
|
const builder = build(new foreign_key_constraint_builder_js_1.ForeignKeyConstraintBuilder(foreign_key_constraint_node_js_1.ForeignKeyConstraintNode.create(columns.map(column_node_js_1.ColumnNode.create), table_node_js_1.TableNode.create(targetTable), targetColumns.map(column_node_js_1.ColumnNode.create), constraintName)));
|
|
164
167
|
return new CreateTableBuilder({
|
|
165
168
|
...this.#props,
|
|
166
|
-
createTableNode: create_table_node_js_1.CreateTableNode.
|
|
169
|
+
createTableNode: create_table_node_js_1.CreateTableNode.cloneWithConstraint(this.#props.createTableNode, builder.toOperationNode()),
|
|
167
170
|
});
|
|
168
171
|
}
|
|
169
172
|
toOperationNode() {
|
|
@@ -13,5 +13,5 @@ export interface CreateSchemaNode extends OperationNode {
|
|
|
13
13
|
export declare const CreateSchemaNode: Readonly<{
|
|
14
14
|
is(node: OperationNode): node is CreateSchemaNode;
|
|
15
15
|
create(schema: string, params?: CreateSchemaNodeParams | undefined): CreateSchemaNode;
|
|
16
|
-
|
|
16
|
+
cloneWith(createSchema: CreateSchemaNode, params: CreateSchemaNodeParams): CreateSchemaNode;
|
|
17
17
|
}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node.js';
|
|
2
2
|
import { TableNode } from './table-node.js';
|
|
3
|
-
import { ForeignKeyConstraintNode } from './foreign-key-constraint-node.js';
|
|
4
3
|
import { ConstraintNode } from './constraint-node.js';
|
|
5
4
|
import { ColumnDefinitionNode } from './column-definition-node.js';
|
|
6
5
|
export declare type CreateTableNodeModifier = 'IfNotExists';
|
|
@@ -19,8 +18,5 @@ export declare const CreateTableNode: Readonly<{
|
|
|
19
18
|
create(table: TableNode): CreateTableNode;
|
|
20
19
|
cloneWithColumn(createTable: CreateTableNode, column: ColumnDefinitionNode): CreateTableNode;
|
|
21
20
|
cloneWithModifier(createTable: CreateTableNode, modifier: CreateTableNodeModifier): CreateTableNode;
|
|
22
|
-
|
|
23
|
-
cloneWithUniqueConstraint(createTable: CreateTableNode, constraintName: string, columns: string[]): CreateTableNode;
|
|
24
|
-
cloneWithCheckConstraint(createTable: CreateTableNode, constraintName: string, sql: string): CreateTableNode;
|
|
25
|
-
cloneWithForeignKeyConstraint(createTable: CreateTableNode, constraint: ForeignKeyConstraintNode): CreateTableNode;
|
|
21
|
+
cloneWithConstraint(createTable: CreateTableNode, constraint: ConstraintNode): CreateTableNode;
|
|
26
22
|
}>;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { freeze } from '../util/object-utils.js';
|
|
2
|
-
import { CheckConstraintNode } from './check-constraint-node.js';
|
|
3
|
-
import { PrimaryConstraintNode } from './primary-constraint-node.js';
|
|
4
|
-
import { UniqueConstraintNode } from './unique-constraint-node.js';
|
|
5
2
|
/**
|
|
6
3
|
* @internal
|
|
7
4
|
*/
|
|
@@ -28,34 +25,7 @@ export const CreateTableNode = freeze({
|
|
|
28
25
|
modifier,
|
|
29
26
|
});
|
|
30
27
|
},
|
|
31
|
-
|
|
32
|
-
const constraint = PrimaryConstraintNode.create(columns, constraintName);
|
|
33
|
-
return freeze({
|
|
34
|
-
...createTable,
|
|
35
|
-
constraints: createTable.constraints
|
|
36
|
-
? freeze([...createTable.constraints, constraint])
|
|
37
|
-
: freeze([constraint]),
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
cloneWithUniqueConstraint(createTable, constraintName, columns) {
|
|
41
|
-
const constraint = UniqueConstraintNode.create(columns, constraintName);
|
|
42
|
-
return freeze({
|
|
43
|
-
...createTable,
|
|
44
|
-
constraints: createTable.constraints
|
|
45
|
-
? freeze([...createTable.constraints, constraint])
|
|
46
|
-
: freeze([constraint]),
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
cloneWithCheckConstraint(createTable, constraintName, sql) {
|
|
50
|
-
const constraint = CheckConstraintNode.create(sql, constraintName);
|
|
51
|
-
return freeze({
|
|
52
|
-
...createTable,
|
|
53
|
-
constraints: createTable.constraints
|
|
54
|
-
? freeze([...createTable.constraints, constraint])
|
|
55
|
-
: freeze([constraint]),
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
cloneWithForeignKeyConstraint(createTable, constraint) {
|
|
28
|
+
cloneWithConstraint(createTable, constraint) {
|
|
59
29
|
return freeze({
|
|
60
30
|
...createTable,
|
|
61
31
|
constraints: createTable.constraints
|
|
@@ -2,4 +2,4 @@ import { OperationNode } from './operation-node.js';
|
|
|
2
2
|
export interface OperationNodeSource {
|
|
3
3
|
toOperationNode(): OperationNode;
|
|
4
4
|
}
|
|
5
|
-
export declare function isOperationNodeSource(obj:
|
|
5
|
+
export declare function isOperationNodeSource(obj: unknown): obj is OperationNodeSource;
|
|
@@ -453,11 +453,12 @@ export class OperationNodeTransformer {
|
|
|
453
453
|
kind: 'AlterTableNode',
|
|
454
454
|
table: this.transformNode(node.table),
|
|
455
455
|
renameTo: this.transformNode(node.renameTo),
|
|
456
|
-
renameColumn: this.transformNode(node.renameColumn),
|
|
457
456
|
setSchema: this.transformNode(node.setSchema),
|
|
457
|
+
renameColumn: this.transformNode(node.renameColumn),
|
|
458
458
|
addColumn: this.transformNode(node.addColumn),
|
|
459
459
|
dropColumn: this.transformNode(node.dropColumn),
|
|
460
460
|
alterColumn: this.transformNode(node.alterColumn),
|
|
461
|
+
modifyColumn: this.transformNode(node.modifyColumn),
|
|
461
462
|
addConstraint: this.transformNode(node.addConstraint),
|
|
462
463
|
dropConstraint: this.transformNode(node.dropConstraint),
|
|
463
464
|
};
|
|
@@ -9,7 +9,7 @@ export class CreateSchemaBuilder {
|
|
|
9
9
|
ifNotExists() {
|
|
10
10
|
return new CreateSchemaBuilder({
|
|
11
11
|
...this.#props,
|
|
12
|
-
createSchemaNode: CreateSchemaNode.
|
|
12
|
+
createSchemaNode: CreateSchemaNode.cloneWith(this.#props.createSchemaNode, { modifier: 'IfNotExists' }),
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
toOperationNode() {
|
|
@@ -8,6 +8,9 @@ import { ColumnNode } from '../operation-node/column-node.js';
|
|
|
8
8
|
import { TableNode } from '../operation-node/table-node.js';
|
|
9
9
|
import { ForeignKeyConstraintBuilder } from './foreign-key-constraint-builder.js';
|
|
10
10
|
import { parseDataTypeExpression, } from '../parser/data-type-parser.js';
|
|
11
|
+
import { PrimaryConstraintNode } from '../operation-node/primary-constraint-node.js';
|
|
12
|
+
import { UniqueConstraintNode } from '../operation-node/unique-constraint-node.js';
|
|
13
|
+
import { CheckConstraintNode } from '../operation-node/check-constraint-node.js';
|
|
11
14
|
/**
|
|
12
15
|
* This builder can be used to create a `create table` query.
|
|
13
16
|
*/
|
|
@@ -92,7 +95,7 @@ export class CreateTableBuilder {
|
|
|
92
95
|
addPrimaryKeyConstraint(constraintName, columns) {
|
|
93
96
|
return new CreateTableBuilder({
|
|
94
97
|
...this.#props,
|
|
95
|
-
createTableNode: CreateTableNode.
|
|
98
|
+
createTableNode: CreateTableNode.cloneWithConstraint(this.#props.createTableNode, PrimaryConstraintNode.create(columns, constraintName)),
|
|
96
99
|
});
|
|
97
100
|
}
|
|
98
101
|
/**
|
|
@@ -109,7 +112,7 @@ export class CreateTableBuilder {
|
|
|
109
112
|
addUniqueConstraint(constraintName, columns) {
|
|
110
113
|
return new CreateTableBuilder({
|
|
111
114
|
...this.#props,
|
|
112
|
-
createTableNode: CreateTableNode.
|
|
115
|
+
createTableNode: CreateTableNode.cloneWithConstraint(this.#props.createTableNode, UniqueConstraintNode.create(columns, constraintName)),
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
/**
|
|
@@ -126,7 +129,7 @@ export class CreateTableBuilder {
|
|
|
126
129
|
addCheckConstraint(constraintName, checkExpression) {
|
|
127
130
|
return new CreateTableBuilder({
|
|
128
131
|
...this.#props,
|
|
129
|
-
createTableNode: CreateTableNode.
|
|
132
|
+
createTableNode: CreateTableNode.cloneWithConstraint(this.#props.createTableNode, CheckConstraintNode.create(checkExpression, constraintName)),
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
135
|
/**
|
|
@@ -160,7 +163,7 @@ export class CreateTableBuilder {
|
|
|
160
163
|
const builder = build(new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(columns.map(ColumnNode.create), TableNode.create(targetTable), targetColumns.map(ColumnNode.create), constraintName)));
|
|
161
164
|
return new CreateTableBuilder({
|
|
162
165
|
...this.#props,
|
|
163
|
-
createTableNode: CreateTableNode.
|
|
166
|
+
createTableNode: CreateTableNode.cloneWithConstraint(this.#props.createTableNode, builder.toOperationNode()),
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
169
|
toOperationNode() {
|