kysely 0.9.9 → 0.10.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/README.md +15 -13
- package/dist/cjs/operation-node/column-definition-node.d.ts +4 -4
- package/dist/cjs/operation-node/column-definition-node.js +4 -4
- package/dist/cjs/operation-node/create-schema-node.d.ts +1 -2
- package/dist/cjs/operation-node/create-table-node.d.ts +2 -3
- package/dist/cjs/operation-node/create-table-node.js +2 -2
- package/dist/cjs/operation-node/create-view-node.d.ts +2 -2
- package/dist/cjs/operation-node/drop-index-node.d.ts +1 -2
- package/dist/cjs/operation-node/drop-schema-node.d.ts +2 -3
- package/dist/cjs/operation-node/drop-schema-node.js +2 -2
- package/dist/cjs/operation-node/drop-table-node.d.ts +2 -3
- package/dist/cjs/operation-node/drop-table-node.js +2 -2
- package/dist/cjs/operation-node/drop-view-node.d.ts +3 -3
- package/dist/cjs/operation-node/drop-view-node.js +2 -2
- package/dist/cjs/operation-node/operation-node-transformer.js +13 -11
- package/dist/cjs/operation-node/select-query-node.d.ts +1 -1
- package/dist/cjs/operation-node/select-query-node.js +1 -1
- package/dist/cjs/query-compiler/default-query-compiler.js +20 -13
- package/dist/cjs/schema/alter-table-builder.d.ts +2 -2
- package/dist/cjs/schema/alter-table-builder.js +4 -4
- package/dist/cjs/schema/column-definition-builder.d.ts +2 -2
- package/dist/cjs/schema/column-definition-builder.js +5 -5
- package/dist/cjs/schema/create-schema-builder.js +1 -1
- package/dist/cjs/schema/create-table-builder.d.ts +1 -1
- package/dist/cjs/schema/create-table-builder.js +2 -2
- package/dist/cjs/schema/create-view-builder.d.ts +1 -0
- package/dist/cjs/schema/create-view-builder.js +9 -1
- package/dist/cjs/schema/drop-index-builder.js +1 -1
- package/dist/cjs/schema/drop-schema-builder.js +3 -1
- package/dist/cjs/schema/drop-table-builder.js +3 -1
- package/dist/cjs/schema/drop-view-builder.d.ts +1 -0
- package/dist/cjs/schema/drop-view-builder.js +11 -1
- package/dist/cjs/schema/schema.d.ts +3 -3
- package/dist/cjs/schema/schema.js +3 -3
- package/dist/esm/operation-node/column-definition-node.d.ts +4 -4
- package/dist/esm/operation-node/column-definition-node.js +4 -4
- package/dist/esm/operation-node/create-schema-node.d.ts +1 -2
- package/dist/esm/operation-node/create-table-node.d.ts +2 -3
- package/dist/esm/operation-node/create-table-node.js +2 -2
- package/dist/esm/operation-node/create-view-node.d.ts +2 -2
- package/dist/esm/operation-node/drop-index-node.d.ts +1 -2
- package/dist/esm/operation-node/drop-schema-node.d.ts +2 -3
- package/dist/esm/operation-node/drop-schema-node.js +2 -2
- package/dist/esm/operation-node/drop-table-node.d.ts +2 -3
- package/dist/esm/operation-node/drop-table-node.js +2 -2
- package/dist/esm/operation-node/drop-view-node.d.ts +3 -3
- package/dist/esm/operation-node/drop-view-node.js +2 -2
- package/dist/esm/operation-node/operation-node-transformer.js +13 -11
- package/dist/esm/operation-node/select-query-node.d.ts +1 -1
- package/dist/esm/operation-node/select-query-node.js +1 -1
- package/dist/esm/query-compiler/default-query-compiler.js +20 -13
- package/dist/esm/schema/alter-table-builder.d.ts +2 -2
- package/dist/esm/schema/alter-table-builder.js +4 -4
- package/dist/esm/schema/column-definition-builder.d.ts +2 -2
- package/dist/esm/schema/column-definition-builder.js +5 -5
- package/dist/esm/schema/create-schema-builder.js +1 -1
- package/dist/esm/schema/create-table-builder.d.ts +1 -1
- package/dist/esm/schema/create-table-builder.js +2 -2
- package/dist/esm/schema/create-view-builder.d.ts +1 -0
- package/dist/esm/schema/create-view-builder.js +9 -1
- package/dist/esm/schema/drop-index-builder.js +1 -1
- package/dist/esm/schema/drop-schema-builder.js +3 -1
- package/dist/esm/schema/drop-table-builder.js +3 -1
- package/dist/esm/schema/drop-view-builder.d.ts +1 -0
- package/dist/esm/schema/drop-view-builder.js +11 -1
- package/dist/esm/schema/schema.d.ts +3 -3
- package/dist/esm/schema/schema.js +3 -3
- package/package.json +1 -1
|
@@ -12,7 +12,9 @@ class DropSchemaBuilder {
|
|
|
12
12
|
ifExists() {
|
|
13
13
|
return new DropSchemaBuilder({
|
|
14
14
|
...this.#props,
|
|
15
|
-
dropSchemaNode: drop_schema_node_js_1.DropSchemaNode.
|
|
15
|
+
dropSchemaNode: drop_schema_node_js_1.DropSchemaNode.cloneWith(this.#props.dropSchemaNode, {
|
|
16
|
+
ifExists: true,
|
|
17
|
+
}),
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
toOperationNode() {
|
|
@@ -12,7 +12,9 @@ class DropTableBuilder {
|
|
|
12
12
|
ifExists() {
|
|
13
13
|
return new DropTableBuilder({
|
|
14
14
|
...this.#props,
|
|
15
|
-
dropTableNode: drop_table_node_js_1.DropTableNode.
|
|
15
|
+
dropTableNode: drop_table_node_js_1.DropTableNode.cloneWith(this.#props.dropTableNode, {
|
|
16
|
+
ifExists: true,
|
|
17
|
+
}),
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
toOperationNode() {
|
|
@@ -7,6 +7,7 @@ import { DropViewNode } from '../operation-node/drop-view-node.js';
|
|
|
7
7
|
export declare class DropViewBuilder implements OperationNodeSource, Compilable {
|
|
8
8
|
#private;
|
|
9
9
|
constructor(props: DropViewBuilderProps);
|
|
10
|
+
materialized(): DropViewBuilder;
|
|
10
11
|
ifExists(): DropViewBuilder;
|
|
11
12
|
toOperationNode(): DropViewNode;
|
|
12
13
|
compile(): CompiledQuery;
|
|
@@ -9,10 +9,20 @@ class DropViewBuilder {
|
|
|
9
9
|
constructor(props) {
|
|
10
10
|
this.#props = (0, object_utils_js_1.freeze)(props);
|
|
11
11
|
}
|
|
12
|
+
materialized() {
|
|
13
|
+
return new DropViewBuilder({
|
|
14
|
+
...this.#props,
|
|
15
|
+
dropViewNode: drop_view_node_js_1.DropViewNode.cloneWith(this.#props.dropViewNode, {
|
|
16
|
+
materialized: true,
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
12
20
|
ifExists() {
|
|
13
21
|
return new DropViewBuilder({
|
|
14
22
|
...this.#props,
|
|
15
|
-
dropViewNode: drop_view_node_js_1.DropViewNode.
|
|
23
|
+
dropViewNode: drop_view_node_js_1.DropViewNode.cloneWith(this.#props.dropViewNode, {
|
|
24
|
+
ifExists: true,
|
|
25
|
+
}),
|
|
16
26
|
});
|
|
17
27
|
}
|
|
18
28
|
toOperationNode() {
|
|
@@ -24,7 +24,7 @@ export declare class SchemaModule {
|
|
|
24
24
|
* ```ts
|
|
25
25
|
* await db.schema
|
|
26
26
|
* .createTable('person')
|
|
27
|
-
* .addColumn('id', 'integer', col => col.primaryKey().
|
|
27
|
+
* .addColumn('id', 'integer', col => col.primaryKey().autoIncrement())
|
|
28
28
|
* .addColumn('first_name', 'varchar', col => col.notNull())
|
|
29
29
|
* .addColumn('last_name', 'varchar', col => col.notNull())
|
|
30
30
|
* .addColumn('gender', 'varchar')
|
|
@@ -40,7 +40,7 @@ export declare class SchemaModule {
|
|
|
40
40
|
* ```ts
|
|
41
41
|
* await db.schema
|
|
42
42
|
* .createTable('pet')
|
|
43
|
-
* .addColumn('id', 'integer', col => col.primaryKey().
|
|
43
|
+
* .addColumn('id', 'integer', col => col.primaryKey().autoIncrement())
|
|
44
44
|
* .addColumn('owner_id', 'integer', col => col
|
|
45
45
|
* .references('person.id')
|
|
46
46
|
* .onDelete('cascade')
|
|
@@ -57,7 +57,7 @@ export declare class SchemaModule {
|
|
|
57
57
|
* ```ts
|
|
58
58
|
* await db.schema
|
|
59
59
|
* .createTable('pet')
|
|
60
|
-
* .addColumn('id', 'integer', col => col.primaryKey().
|
|
60
|
+
* .addColumn('id', 'integer', col => col.primaryKey().autoIncrement())
|
|
61
61
|
* .addColumn('owner_id', 'integer')
|
|
62
62
|
* .addForeignKeyConstraint(
|
|
63
63
|
* 'pet_owner_id_foreign', ['owner_id'], 'person', ['id'],
|
|
@@ -40,7 +40,7 @@ class SchemaModule {
|
|
|
40
40
|
* ```ts
|
|
41
41
|
* await db.schema
|
|
42
42
|
* .createTable('person')
|
|
43
|
-
* .addColumn('id', 'integer', col => col.primaryKey().
|
|
43
|
+
* .addColumn('id', 'integer', col => col.primaryKey().autoIncrement())
|
|
44
44
|
* .addColumn('first_name', 'varchar', col => col.notNull())
|
|
45
45
|
* .addColumn('last_name', 'varchar', col => col.notNull())
|
|
46
46
|
* .addColumn('gender', 'varchar')
|
|
@@ -56,7 +56,7 @@ class SchemaModule {
|
|
|
56
56
|
* ```ts
|
|
57
57
|
* await db.schema
|
|
58
58
|
* .createTable('pet')
|
|
59
|
-
* .addColumn('id', 'integer', col => col.primaryKey().
|
|
59
|
+
* .addColumn('id', 'integer', col => col.primaryKey().autoIncrement())
|
|
60
60
|
* .addColumn('owner_id', 'integer', col => col
|
|
61
61
|
* .references('person.id')
|
|
62
62
|
* .onDelete('cascade')
|
|
@@ -73,7 +73,7 @@ class SchemaModule {
|
|
|
73
73
|
* ```ts
|
|
74
74
|
* await db.schema
|
|
75
75
|
* .createTable('pet')
|
|
76
|
-
* .addColumn('id', 'integer', col => col.primaryKey().
|
|
76
|
+
* .addColumn('id', 'integer', col => col.primaryKey().autoIncrement())
|
|
77
77
|
* .addColumn('owner_id', 'integer')
|
|
78
78
|
* .addForeignKeyConstraint(
|
|
79
79
|
* 'pet_owner_id_foreign', ['owner_id'], 'person', ['id'],
|
|
@@ -12,10 +12,10 @@ export interface ColumnDefinitionNode extends OperationNode {
|
|
|
12
12
|
readonly column: ColumnNode;
|
|
13
13
|
readonly dataType: ColumnDataTypeNode;
|
|
14
14
|
readonly references?: ReferencesNode;
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
15
|
+
readonly primaryKey: boolean;
|
|
16
|
+
readonly autoIncrement: boolean;
|
|
17
|
+
readonly unique: boolean;
|
|
18
|
+
readonly nullable: boolean;
|
|
19
19
|
readonly defaultTo?: ValueNode | RawNode;
|
|
20
20
|
readonly check?: CheckConstraintNode;
|
|
21
21
|
}
|
|
@@ -12,10 +12,10 @@ export const ColumnDefinitionNode = freeze({
|
|
|
12
12
|
kind: 'ColumnDefinitionNode',
|
|
13
13
|
column: ColumnNode.create(column),
|
|
14
14
|
dataType,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
primaryKey: false,
|
|
16
|
+
autoIncrement: false,
|
|
17
|
+
unique: false,
|
|
18
|
+
nullable: true,
|
|
19
19
|
});
|
|
20
20
|
},
|
|
21
21
|
cloneWith(node, props) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { IdentifierNode } from './identifier-node.js';
|
|
2
2
|
import { OperationNode } from './operation-node.js';
|
|
3
|
-
export declare type CreateSchemaNodeModifier = 'IfNotExists';
|
|
4
3
|
export declare type CreateSchemaNodeParams = Omit<Partial<CreateSchemaNode>, 'kind' | 'schema'>;
|
|
5
4
|
export interface CreateSchemaNode extends OperationNode {
|
|
6
5
|
readonly kind: 'CreateSchemaNode';
|
|
7
6
|
readonly schema: IdentifierNode;
|
|
8
|
-
readonly
|
|
7
|
+
readonly ifNotExists?: boolean;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
10
|
* @internal
|
|
@@ -2,12 +2,11 @@ import { OperationNode } from './operation-node.js';
|
|
|
2
2
|
import { TableNode } from './table-node.js';
|
|
3
3
|
import { ConstraintNode } from './constraint-node.js';
|
|
4
4
|
import { ColumnDefinitionNode } from './column-definition-node.js';
|
|
5
|
-
export declare type CreateTableNodeModifier = 'IfNotExists';
|
|
6
5
|
export interface CreateTableNode extends OperationNode {
|
|
7
6
|
readonly kind: 'CreateTableNode';
|
|
8
7
|
readonly table: TableNode;
|
|
9
8
|
readonly columns: ReadonlyArray<ColumnDefinitionNode>;
|
|
10
|
-
readonly
|
|
9
|
+
readonly ifNotExists?: boolean;
|
|
11
10
|
readonly constraints?: ReadonlyArray<ConstraintNode>;
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
@@ -17,6 +16,6 @@ export declare const CreateTableNode: Readonly<{
|
|
|
17
16
|
is(node: OperationNode): node is CreateTableNode;
|
|
18
17
|
create(table: TableNode): CreateTableNode;
|
|
19
18
|
cloneWithColumn(createTable: CreateTableNode, column: ColumnDefinitionNode): CreateTableNode;
|
|
20
|
-
|
|
19
|
+
cloneWithIfNotExists(createTable: CreateTableNode, ifNotExists: boolean): CreateTableNode;
|
|
21
20
|
cloneWithConstraint(createTable: CreateTableNode, constraint: ConstraintNode): CreateTableNode;
|
|
22
21
|
}>;
|
|
@@ -19,10 +19,10 @@ export const CreateTableNode = freeze({
|
|
|
19
19
|
columns: freeze([...createTable.columns, column]),
|
|
20
20
|
});
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
cloneWithIfNotExists(createTable, ifNotExists) {
|
|
23
23
|
return freeze({
|
|
24
24
|
...createTable,
|
|
25
|
-
|
|
25
|
+
ifNotExists,
|
|
26
26
|
});
|
|
27
27
|
},
|
|
28
28
|
cloneWithConstraint(createTable, constraint) {
|
|
@@ -3,12 +3,12 @@ import { IdentifierNode } from './identifier-node.js';
|
|
|
3
3
|
import { OperationNode } from './operation-node.js';
|
|
4
4
|
import { RawNode } from './raw-node.js';
|
|
5
5
|
import { SelectQueryNode } from './select-query-node.js';
|
|
6
|
-
export declare type CreateViewNodeModifier = 'OrReplace';
|
|
7
6
|
export declare type CreateViewNodeParams = Omit<Partial<CreateViewNode>, 'kind' | 'name'>;
|
|
8
7
|
export interface CreateViewNode extends OperationNode {
|
|
9
8
|
readonly kind: 'CreateViewNode';
|
|
10
9
|
readonly name: IdentifierNode;
|
|
11
|
-
readonly
|
|
10
|
+
readonly materialized?: boolean;
|
|
11
|
+
readonly orReplace?: boolean;
|
|
12
12
|
readonly columns?: ReadonlyArray<ColumnNode>;
|
|
13
13
|
readonly as?: SelectQueryNode | RawNode;
|
|
14
14
|
}
|
|
@@ -2,12 +2,11 @@ import { IdentifierNode } from './identifier-node.js';
|
|
|
2
2
|
import { OperationNode } from './operation-node.js';
|
|
3
3
|
import { TableNode } from './table-node.js';
|
|
4
4
|
export declare type DropIndexNodeProps = Omit<DropIndexNode, 'kind' | 'name'>;
|
|
5
|
-
export declare type DropIndexNodeModifier = 'IfExists';
|
|
6
5
|
export interface DropIndexNode extends OperationNode {
|
|
7
6
|
readonly kind: 'DropIndexNode';
|
|
8
7
|
readonly name: IdentifierNode;
|
|
9
8
|
readonly table?: TableNode;
|
|
10
|
-
readonly
|
|
9
|
+
readonly ifExists?: boolean;
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
12
|
* @internal
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { IdentifierNode } from './identifier-node.js';
|
|
2
2
|
import { OperationNode } from './operation-node.js';
|
|
3
|
-
export declare type DropSchemaNodeModifier = 'IfExists';
|
|
4
3
|
export declare type DropSchemaNodeParams = Omit<Partial<DropSchemaNode>, 'kind' | 'schema'>;
|
|
5
4
|
export interface DropSchemaNode extends OperationNode {
|
|
6
5
|
readonly kind: 'DropSchemaNode';
|
|
7
6
|
readonly schema: IdentifierNode;
|
|
8
|
-
readonly
|
|
7
|
+
readonly ifExists?: boolean;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
10
|
* @internal
|
|
@@ -13,5 +12,5 @@ export interface DropSchemaNode extends OperationNode {
|
|
|
13
12
|
export declare const DropSchemaNode: Readonly<{
|
|
14
13
|
is(node: OperationNode): node is DropSchemaNode;
|
|
15
14
|
create(schema: string, params?: DropSchemaNodeParams | undefined): DropSchemaNode;
|
|
16
|
-
|
|
15
|
+
cloneWith(dropSchema: DropSchemaNode, params: DropSchemaNodeParams): DropSchemaNode;
|
|
17
16
|
}>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node.js';
|
|
2
2
|
import { TableNode } from './table-node.js';
|
|
3
3
|
export declare type DropTablexNodeParams = Omit<Partial<DropTableNode>, 'kind' | 'table'>;
|
|
4
|
-
export declare type DropTableNodeModifier = 'IfExists';
|
|
5
4
|
export interface DropTableNode extends OperationNode {
|
|
6
5
|
readonly kind: 'DropTableNode';
|
|
7
6
|
readonly table: TableNode;
|
|
8
|
-
readonly
|
|
7
|
+
readonly ifExists?: boolean;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
10
|
* @internal
|
|
@@ -13,5 +12,5 @@ export interface DropTableNode extends OperationNode {
|
|
|
13
12
|
export declare const DropTableNode: Readonly<{
|
|
14
13
|
is(node: OperationNode): node is DropTableNode;
|
|
15
14
|
create(table: TableNode, params?: DropTablexNodeParams | undefined): DropTableNode;
|
|
16
|
-
|
|
15
|
+
cloneWith(dropIndex: DropTableNode, params: DropTablexNodeParams): DropTableNode;
|
|
17
16
|
}>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IdentifierNode } from './identifier-node.js';
|
|
2
2
|
import { OperationNode } from './operation-node.js';
|
|
3
|
-
export declare type DropViewNodeModifier = 'IfExists';
|
|
4
3
|
export declare type DropViewNodeParams = Omit<Partial<DropViewNode>, 'kind' | 'name'>;
|
|
5
4
|
export interface DropViewNode extends OperationNode {
|
|
6
5
|
readonly kind: 'DropViewNode';
|
|
7
6
|
readonly name: IdentifierNode;
|
|
8
|
-
readonly
|
|
7
|
+
readonly ifExists?: boolean;
|
|
8
|
+
readonly materialized?: boolean;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
@@ -13,5 +13,5 @@ export interface DropViewNode extends OperationNode {
|
|
|
13
13
|
export declare const DropViewNode: Readonly<{
|
|
14
14
|
is(node: OperationNode): node is DropViewNode;
|
|
15
15
|
create(name: string): DropViewNode;
|
|
16
|
-
|
|
16
|
+
cloneWith(dropView: DropViewNode, params: DropViewNodeParams): DropViewNode;
|
|
17
17
|
}>;
|
|
@@ -114,7 +114,7 @@ export class OperationNodeTransformer {
|
|
|
114
114
|
from: this.transformNode(node.from),
|
|
115
115
|
selections: this.transformNodeList(node.selections),
|
|
116
116
|
distinctOnSelections: this.transformNodeList(node.distinctOnSelections),
|
|
117
|
-
|
|
117
|
+
distinct: node.distinct,
|
|
118
118
|
joins: this.transformNodeList(node.joins),
|
|
119
119
|
groupBy: this.transformNode(node.groupBy),
|
|
120
120
|
orderBy: this.transformNode(node.orderBy),
|
|
@@ -256,7 +256,7 @@ export class OperationNodeTransformer {
|
|
|
256
256
|
table: this.transformNode(node.table),
|
|
257
257
|
columns: this.transformNodeList(node.columns),
|
|
258
258
|
constraints: this.transformNodeList(node.constraints),
|
|
259
|
-
|
|
259
|
+
ifNotExists: node.ifNotExists,
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
transformColumnDefinition(node) {
|
|
@@ -265,10 +265,10 @@ export class OperationNodeTransformer {
|
|
|
265
265
|
column: this.transformNode(node.column),
|
|
266
266
|
dataType: this.transformNode(node.dataType),
|
|
267
267
|
references: this.transformNode(node.references),
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
primaryKey: node.primaryKey,
|
|
269
|
+
autoIncrement: node.autoIncrement,
|
|
270
|
+
unique: node.unique,
|
|
271
|
+
nullable: node.nullable,
|
|
272
272
|
defaultTo: this.transformNode(node.defaultTo),
|
|
273
273
|
check: this.transformNode(node.check),
|
|
274
274
|
};
|
|
@@ -283,7 +283,7 @@ export class OperationNodeTransformer {
|
|
|
283
283
|
return {
|
|
284
284
|
kind: 'DropTableNode',
|
|
285
285
|
table: this.transformNode(node.table),
|
|
286
|
-
|
|
286
|
+
ifExists: node.ifExists,
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
289
|
transformOrderBy(node) {
|
|
@@ -377,7 +377,7 @@ export class OperationNodeTransformer {
|
|
|
377
377
|
kind: 'DropIndexNode',
|
|
378
378
|
name: this.transformNode(node.name),
|
|
379
379
|
table: this.transformNode(node.table),
|
|
380
|
-
|
|
380
|
+
ifExists: node.ifExists,
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
383
|
transformPrimaryKeyConstraint(node) {
|
|
@@ -456,7 +456,7 @@ export class OperationNodeTransformer {
|
|
|
456
456
|
return {
|
|
457
457
|
kind: 'DropSchemaNode',
|
|
458
458
|
schema: this.transformNode(node.schema),
|
|
459
|
-
|
|
459
|
+
ifExists: node.ifExists,
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
462
|
transformAlterTable(node) {
|
|
@@ -521,7 +521,8 @@ export class OperationNodeTransformer {
|
|
|
521
521
|
return {
|
|
522
522
|
kind: 'CreateViewNode',
|
|
523
523
|
name: this.transformNode(node.name),
|
|
524
|
-
|
|
524
|
+
orReplace: node.orReplace,
|
|
525
|
+
materialized: node.materialized,
|
|
525
526
|
columns: this.transformNodeList(node.columns),
|
|
526
527
|
as: this.transformNode(node.as),
|
|
527
528
|
};
|
|
@@ -530,7 +531,8 @@ export class OperationNodeTransformer {
|
|
|
530
531
|
return {
|
|
531
532
|
kind: 'DropViewNode',
|
|
532
533
|
name: this.transformNode(node.name),
|
|
533
|
-
|
|
534
|
+
ifExists: node.ifExists,
|
|
535
|
+
materialized: node.materialized,
|
|
534
536
|
};
|
|
535
537
|
}
|
|
536
538
|
transformDataType(node) {
|
|
@@ -19,7 +19,7 @@ export interface SelectQueryNode extends OperationNode {
|
|
|
19
19
|
readonly from: FromNode;
|
|
20
20
|
readonly selections?: ReadonlyArray<SelectionNode>;
|
|
21
21
|
readonly distinctOnSelections?: ReadonlyArray<SelectionNode>;
|
|
22
|
-
readonly
|
|
22
|
+
readonly distinct?: boolean;
|
|
23
23
|
readonly joins?: ReadonlyArray<JoinNode>;
|
|
24
24
|
readonly groupBy?: GroupByNode;
|
|
25
25
|
readonly orderBy?: OrderByNode;
|
|
@@ -35,7 +35,7 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
35
35
|
this.compileDistinctOn(node.distinctOnSelections);
|
|
36
36
|
this.append(' ');
|
|
37
37
|
}
|
|
38
|
-
if (node.
|
|
38
|
+
if (node.distinct) {
|
|
39
39
|
this.append('distinct');
|
|
40
40
|
this.append(' ');
|
|
41
41
|
}
|
|
@@ -287,7 +287,7 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
287
287
|
}
|
|
288
288
|
visitCreateTable(node) {
|
|
289
289
|
this.append('create table ');
|
|
290
|
-
if (node.
|
|
290
|
+
if (node.ifNotExists) {
|
|
291
291
|
this.append('if not exists ');
|
|
292
292
|
}
|
|
293
293
|
this.visitNode(node.table);
|
|
@@ -303,17 +303,17 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
303
303
|
this.append(' default ');
|
|
304
304
|
this.visitNode(node.defaultTo);
|
|
305
305
|
}
|
|
306
|
-
if (!node.
|
|
306
|
+
if (!node.nullable) {
|
|
307
307
|
this.append(' not null');
|
|
308
308
|
}
|
|
309
|
-
if (node.
|
|
309
|
+
if (node.autoIncrement) {
|
|
310
310
|
this.append(' ');
|
|
311
311
|
this.append(this.getAutoIncrement());
|
|
312
312
|
}
|
|
313
|
-
if (node.
|
|
313
|
+
if (node.unique) {
|
|
314
314
|
this.append(' unique');
|
|
315
315
|
}
|
|
316
|
-
if (node.
|
|
316
|
+
if (node.primaryKey) {
|
|
317
317
|
this.append(' primary key');
|
|
318
318
|
}
|
|
319
319
|
if (node.references) {
|
|
@@ -345,7 +345,7 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
345
345
|
}
|
|
346
346
|
visitDropTable(node) {
|
|
347
347
|
this.append('drop table ');
|
|
348
|
-
if (node.
|
|
348
|
+
if (node.ifExists) {
|
|
349
349
|
this.append('if exists ');
|
|
350
350
|
}
|
|
351
351
|
this.visitNode(node.table);
|
|
@@ -467,7 +467,7 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
467
467
|
}
|
|
468
468
|
visitDropIndex(node) {
|
|
469
469
|
this.append('drop index ');
|
|
470
|
-
if (node.
|
|
470
|
+
if (node.ifExists) {
|
|
471
471
|
this.append('if exists ');
|
|
472
472
|
}
|
|
473
473
|
this.visitNode(node.name);
|
|
@@ -478,14 +478,14 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
478
478
|
}
|
|
479
479
|
visitCreateSchema(node) {
|
|
480
480
|
this.append('create schema ');
|
|
481
|
-
if (node.
|
|
481
|
+
if (node.ifNotExists) {
|
|
482
482
|
this.append('if not exists ');
|
|
483
483
|
}
|
|
484
484
|
this.visitNode(node.schema);
|
|
485
485
|
}
|
|
486
486
|
visitDropSchema(node) {
|
|
487
487
|
this.append('drop schema ');
|
|
488
|
-
if (node.
|
|
488
|
+
if (node.ifExists) {
|
|
489
489
|
this.append('if exists ');
|
|
490
490
|
}
|
|
491
491
|
this.visitNode(node.schema);
|
|
@@ -646,9 +646,12 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
646
646
|
}
|
|
647
647
|
visitCreateView(node) {
|
|
648
648
|
this.append('create ');
|
|
649
|
-
if (node.
|
|
649
|
+
if (node.orReplace) {
|
|
650
650
|
this.append('or replace ');
|
|
651
651
|
}
|
|
652
|
+
if (node.materialized) {
|
|
653
|
+
this.append('materialized ');
|
|
654
|
+
}
|
|
652
655
|
this.append('view ');
|
|
653
656
|
this.visitNode(node.name);
|
|
654
657
|
this.append(' ');
|
|
@@ -663,8 +666,12 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
|
|
|
663
666
|
}
|
|
664
667
|
}
|
|
665
668
|
visitDropView(node) {
|
|
666
|
-
this.append('drop
|
|
667
|
-
if (node.
|
|
669
|
+
this.append('drop ');
|
|
670
|
+
if (node.materialized) {
|
|
671
|
+
this.append('materialized ');
|
|
672
|
+
}
|
|
673
|
+
this.append('view ');
|
|
674
|
+
if (node.ifExists) {
|
|
668
675
|
this.append('if exists ');
|
|
669
676
|
}
|
|
670
677
|
this.visitNode(node.name);
|
|
@@ -63,7 +63,7 @@ export interface AlterTableExecutorProps extends AlterTableBuilderProps {
|
|
|
63
63
|
export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuilderInterface<AlterTableAddColumnBuilder>, OperationNodeSource, Compilable {
|
|
64
64
|
#private;
|
|
65
65
|
constructor(props: AlterTableAddColumnBuilderProps);
|
|
66
|
-
|
|
66
|
+
autoIncrement(): AlterTableAddColumnBuilder;
|
|
67
67
|
primaryKey(): AlterTableAddColumnBuilder;
|
|
68
68
|
references(ref: string): AlterTableAddColumnBuilder;
|
|
69
69
|
onDelete(onDelete: OnModifyForeignAction): AlterTableAddColumnBuilder;
|
|
@@ -82,7 +82,7 @@ export interface AlterTableAddColumnBuilderProps extends AlterTableBuilderProps
|
|
|
82
82
|
export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBuilderInterface<AlterTableModifyColumnBuilder>, OperationNodeSource, Compilable {
|
|
83
83
|
#private;
|
|
84
84
|
constructor(props: AlterTableModifyColumnBuilderProps);
|
|
85
|
-
|
|
85
|
+
autoIncrement(): AlterTableModifyColumnBuilder;
|
|
86
86
|
primaryKey(): AlterTableModifyColumnBuilder;
|
|
87
87
|
references(ref: string): AlterTableModifyColumnBuilder;
|
|
88
88
|
onDelete(onDelete: OnModifyForeignAction): AlterTableModifyColumnBuilder;
|
|
@@ -184,10 +184,10 @@ export class AlterTableAddColumnBuilder {
|
|
|
184
184
|
constructor(props) {
|
|
185
185
|
this.#props = freeze(props);
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
autoIncrement() {
|
|
188
188
|
return new AlterTableAddColumnBuilder({
|
|
189
189
|
...this.#props,
|
|
190
|
-
columnBuilder: this.#props.columnBuilder.
|
|
190
|
+
columnBuilder: this.#props.columnBuilder.autoIncrement(),
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
primaryKey() {
|
|
@@ -255,10 +255,10 @@ export class AlterTableModifyColumnBuilder {
|
|
|
255
255
|
constructor(props) {
|
|
256
256
|
this.#props = freeze(props);
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
autoIncrement() {
|
|
259
259
|
return new AlterTableModifyColumnBuilder({
|
|
260
260
|
...this.#props,
|
|
261
|
-
columnBuilder: this.#props.columnBuilder.
|
|
261
|
+
columnBuilder: this.#props.columnBuilder.autoIncrement(),
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
264
|
primaryKey() {
|
|
@@ -12,7 +12,7 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
12
12
|
* Some dialects like PostgreSQL don't support this. On PostgreSQL
|
|
13
13
|
* you can use the `serial` or `bigserial` data type instead.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
autoIncrement(): R;
|
|
16
16
|
/**
|
|
17
17
|
* Makes the column the primary key.
|
|
18
18
|
*
|
|
@@ -82,7 +82,7 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
82
82
|
export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderInterface<ColumnDefinitionBuilder>, OperationNodeSource {
|
|
83
83
|
#private;
|
|
84
84
|
constructor(node: ColumnDefinitionNode);
|
|
85
|
-
|
|
85
|
+
autoIncrement(): ColumnDefinitionBuilder;
|
|
86
86
|
primaryKey(): ColumnDefinitionBuilder;
|
|
87
87
|
references(ref: string): ColumnDefinitionBuilder;
|
|
88
88
|
onDelete(onDelete: OnModifyForeignAction): ColumnDefinitionBuilder;
|
|
@@ -11,11 +11,11 @@ export class ColumnDefinitionBuilder {
|
|
|
11
11
|
constructor(node) {
|
|
12
12
|
this.#node = node;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
|
|
14
|
+
autoIncrement() {
|
|
15
|
+
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { autoIncrement: true }));
|
|
16
16
|
}
|
|
17
17
|
primaryKey() {
|
|
18
|
-
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
|
|
18
|
+
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { primaryKey: true }));
|
|
19
19
|
}
|
|
20
20
|
references(ref) {
|
|
21
21
|
const references = parseStringReference(ref);
|
|
@@ -45,10 +45,10 @@ export class ColumnDefinitionBuilder {
|
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
47
|
unique() {
|
|
48
|
-
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
|
|
48
|
+
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { unique: true }));
|
|
49
49
|
}
|
|
50
50
|
notNull() {
|
|
51
|
-
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
|
|
51
|
+
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, { nullable: false }));
|
|
52
52
|
}
|
|
53
53
|
defaultTo(value) {
|
|
54
54
|
return new ColumnDefinitionBuilder(ColumnDefinitionNode.cloneWith(this.#node, {
|
|
@@ -9,7 +9,7 @@ export class CreateSchemaBuilder {
|
|
|
9
9
|
ifNotExists() {
|
|
10
10
|
return new CreateSchemaBuilder({
|
|
11
11
|
...this.#props,
|
|
12
|
-
createSchemaNode: CreateSchemaNode.cloneWith(this.#props.createSchemaNode, {
|
|
12
|
+
createSchemaNode: CreateSchemaNode.cloneWith(this.#props.createSchemaNode, { ifNotExists: true }),
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
toOperationNode() {
|