kysely 0.23.1 → 0.23.3
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 +5 -0
- package/dist/cjs/dialect/mysql/mysql-introspector.js +1 -1
- package/dist/cjs/dialect/postgres/postgres-introspector.js +1 -1
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/operation-node/on-conflict-node.d.ts +2 -0
- package/dist/cjs/operation-node/on-conflict-node.js +12 -0
- package/dist/cjs/operation-node/query-node.d.ts +1 -0
- package/dist/cjs/operation-node/query-node.js +6 -0
- package/dist/cjs/operation-node/select-query-node.d.ts +4 -0
- package/dist/cjs/operation-node/select-query-node.js +24 -0
- package/dist/cjs/parser/binary-operation-parser.d.ts +1 -1
- package/dist/cjs/parser/update-set-parser.d.ts +3 -3
- package/dist/cjs/parser/update-set-parser.js +2 -2
- package/dist/cjs/query-builder/delete-query-builder.d.ts +63 -1
- package/dist/cjs/query-builder/delete-query-builder.js +51 -1
- package/dist/cjs/query-builder/insert-query-builder.d.ts +46 -3
- package/dist/cjs/query-builder/insert-query-builder.js +45 -1
- package/dist/cjs/query-builder/on-conflict-builder.d.ts +40 -2
- package/dist/cjs/query-builder/on-conflict-builder.js +12 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +138 -1
- package/dist/cjs/query-builder/select-query-builder.js +146 -1
- package/dist/cjs/query-builder/update-query-builder.d.ts +67 -3
- package/dist/cjs/query-builder/update-query-builder.js +53 -1
- package/dist/cjs/query-builder/where-interface.d.ts +19 -0
- package/dist/cjs/schema/alter-table-add-foreign-key-constraint-builder.d.ts +23 -0
- package/dist/cjs/schema/alter-table-add-foreign-key-constraint-builder.js +38 -0
- package/dist/cjs/schema/alter-table-builder.d.ts +3 -35
- package/dist/cjs/schema/alter-table-builder.js +10 -102
- package/dist/cjs/schema/alter-table-drop-constraint-builder.d.ts +21 -0
- package/dist/cjs/schema/alter-table-drop-constraint-builder.js +54 -0
- package/dist/cjs/schema/alter-table-executor.d.ts +18 -0
- package/dist/cjs/schema/alter-table-executor.js +22 -0
- package/dist/cjs/util/type-error.d.ts +3 -0
- package/dist/cjs/util/type-error.js +2 -0
- package/dist/esm/dialect/mysql/mysql-introspector.js +1 -1
- package/dist/esm/dialect/postgres/postgres-introspector.js +1 -1
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/operation-node/on-conflict-node.d.ts +2 -0
- package/dist/esm/operation-node/on-conflict-node.js +12 -0
- package/dist/esm/operation-node/query-node.d.ts +1 -0
- package/dist/esm/operation-node/query-node.js +6 -0
- package/dist/esm/operation-node/select-query-node.d.ts +4 -0
- package/dist/esm/operation-node/select-query-node.js +24 -0
- package/dist/esm/parser/binary-operation-parser.d.ts +1 -1
- package/dist/esm/parser/update-set-parser.d.ts +3 -3
- package/dist/esm/parser/update-set-parser.js +2 -2
- package/dist/esm/query-builder/delete-query-builder.d.ts +63 -1
- package/dist/esm/query-builder/delete-query-builder.js +51 -1
- package/dist/esm/query-builder/insert-query-builder.d.ts +46 -3
- package/dist/esm/query-builder/insert-query-builder.js +45 -1
- package/dist/esm/query-builder/on-conflict-builder.d.ts +40 -2
- package/dist/esm/query-builder/on-conflict-builder.js +12 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +138 -1
- package/dist/esm/query-builder/select-query-builder.js +146 -1
- package/dist/esm/query-builder/update-query-builder.d.ts +67 -3
- package/dist/esm/query-builder/update-query-builder.js +54 -2
- package/dist/esm/query-builder/where-interface.d.ts +19 -0
- package/dist/esm/schema/alter-table-add-foreign-key-constraint-builder.d.ts +23 -0
- package/dist/esm/schema/alter-table-add-foreign-key-constraint-builder.js +35 -0
- package/dist/esm/schema/alter-table-builder.d.ts +3 -35
- package/dist/esm/schema/alter-table-builder.js +4 -93
- package/dist/esm/schema/alter-table-drop-constraint-builder.d.ts +21 -0
- package/dist/esm/schema/alter-table-drop-constraint-builder.js +51 -0
- package/dist/esm/schema/alter-table-executor.d.ts +18 -0
- package/dist/esm/schema/alter-table-executor.js +19 -0
- package/dist/esm/util/type-error.d.ts +3 -0
- package/dist/esm/util/type-error.js +2 -0
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ import { parseTableExpressionOrList, } from '../parser/table-parser.js';
|
|
|
4
4
|
import { parseSelectExpressionOrList, parseSelectAll, } from '../parser/select-parser.js';
|
|
5
5
|
import { QueryNode } from '../operation-node/query-node.js';
|
|
6
6
|
import { UpdateQueryNode } from '../operation-node/update-query-node.js';
|
|
7
|
-
import { parseUpdateObject
|
|
7
|
+
import { parseUpdateObject } from '../parser/update-set-parser.js';
|
|
8
8
|
import { preventAwait } from '../util/prevent-await.js';
|
|
9
9
|
import { freeze } from '../util/object-utils.js';
|
|
10
10
|
import { UpdateResult } from './update-result.js';
|
|
@@ -65,6 +65,12 @@ export class UpdateQueryBuilder {
|
|
|
65
65
|
queryNode: QueryNode.cloneWithOrWhere(this.#props.queryNode, parseNotExists(arg)),
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
+
clearWhere() {
|
|
69
|
+
return new UpdateQueryBuilder({
|
|
70
|
+
...this.#props,
|
|
71
|
+
queryNode: QueryNode.cloneWithoutWhere(this.#props.queryNode),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
68
74
|
from(from) {
|
|
69
75
|
return new UpdateQueryBuilder({
|
|
70
76
|
...this.#props,
|
|
@@ -208,7 +214,7 @@ export class UpdateQueryBuilder {
|
|
|
208
214
|
*
|
|
209
215
|
* ### Examples
|
|
210
216
|
*
|
|
211
|
-
* The next example uses a helper
|
|
217
|
+
* The next example uses a helper function `log` to log a query:
|
|
212
218
|
*
|
|
213
219
|
* ```ts
|
|
214
220
|
* function log<T extends Compilable>(qb: T): T {
|
|
@@ -278,6 +284,52 @@ export class UpdateQueryBuilder {
|
|
|
278
284
|
castTo() {
|
|
279
285
|
return new UpdateQueryBuilder(this.#props);
|
|
280
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Asserts that query's output row type equals the given type `T`.
|
|
289
|
+
*
|
|
290
|
+
* This method can be used to simplify excessively complex types to make typescript happy
|
|
291
|
+
* and much faster.
|
|
292
|
+
*
|
|
293
|
+
* Kysely uses complex type magic to achieve its type safety. This complexity is sometimes too much
|
|
294
|
+
* for typescript and you get errors like this:
|
|
295
|
+
*
|
|
296
|
+
* ```
|
|
297
|
+
* error TS2589: Type instantiation is excessively deep and possibly infinite.
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* In these case you can often use this method to help typescript a little bit. When you use this
|
|
301
|
+
* method to assert the output type of a query, Kysely can drop the complex output type that
|
|
302
|
+
* consists of multiple nested helper types and replace it with the simple asserted type.
|
|
303
|
+
*
|
|
304
|
+
* Using this method doesn't reduce type safety at all. You have to pass in a type that is
|
|
305
|
+
* structurally equal to the current type.
|
|
306
|
+
*
|
|
307
|
+
* ### Examples
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* const result = await db
|
|
311
|
+
* .with('updated_person', (qb) => qb
|
|
312
|
+
* .updateTable('person')
|
|
313
|
+
* .set(person)
|
|
314
|
+
* .where('id', '=', person.id)
|
|
315
|
+
* .returning('first_name')
|
|
316
|
+
* .assertType<{ first_name: string }>()
|
|
317
|
+
* )
|
|
318
|
+
* .with('updated_pet', (qb) => qb
|
|
319
|
+
* .updateTable('pet')
|
|
320
|
+
* .set(pet)
|
|
321
|
+
* .where('owner_id', '=', person.id)
|
|
322
|
+
* .returning(['name as pet_name', 'species'])
|
|
323
|
+
* .assertType<{ pet_name: string, species: Species }>()
|
|
324
|
+
* )
|
|
325
|
+
* .selectFrom(['updated_person', 'updated_pet'])
|
|
326
|
+
* .selectAll()
|
|
327
|
+
* .executeTakeFirstOrThrow()
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
assertType() {
|
|
331
|
+
return new UpdateQueryBuilder(this.#props);
|
|
332
|
+
}
|
|
281
333
|
/**
|
|
282
334
|
* Returns a copy of this UpdateQueryBuilder instance with the given plugin installed.
|
|
283
335
|
*/
|
|
@@ -387,4 +387,23 @@ export interface WhereInterface<DB, TB extends keyof DB> {
|
|
|
387
387
|
* Just like {@link whereExists} but creates an `or not exists` clause.
|
|
388
388
|
*/
|
|
389
389
|
orWhereNotExists(arg: ExistsExpression<DB, TB>): WhereInterface<DB, TB>;
|
|
390
|
+
/**
|
|
391
|
+
* Clears all where clauses from the query.
|
|
392
|
+
*
|
|
393
|
+
* ### Examples
|
|
394
|
+
*
|
|
395
|
+
* ```ts
|
|
396
|
+
* db.selectFrom('person')
|
|
397
|
+
* .selectAll()
|
|
398
|
+
* .where('id','=',42)
|
|
399
|
+
* .clearWhere()
|
|
400
|
+
* ```
|
|
401
|
+
*
|
|
402
|
+
* The generated SQL(PostgreSQL):
|
|
403
|
+
*
|
|
404
|
+
* ```sql
|
|
405
|
+
* select * from "person"
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
clearWhere(): WhereInterface<DB, TB>;
|
|
390
409
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AlterTableNode } from '../operation-node/alter-table-node.js';
|
|
2
|
+
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
3
|
+
import { OnModifyForeignAction } from '../operation-node/references-node.js';
|
|
4
|
+
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
5
|
+
import { QueryExecutor } from '../query-executor/query-executor.js';
|
|
6
|
+
import { Compilable } from '../util/compilable.js';
|
|
7
|
+
import { QueryId } from '../util/query-id.js';
|
|
8
|
+
import { ForeignKeyConstraintBuilder, ForeignKeyConstraintBuilderInterface } from './foreign-key-constraint-builder.js';
|
|
9
|
+
export declare class AlterTableAddForeignKeyConstraintBuilder implements ForeignKeyConstraintBuilderInterface<AlterTableAddForeignKeyConstraintBuilder>, OperationNodeSource, Compilable {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(props: AlterTableAddForeignKeyConstraintBuilderProps);
|
|
12
|
+
onDelete(onDelete: OnModifyForeignAction): AlterTableAddForeignKeyConstraintBuilder;
|
|
13
|
+
onUpdate(onUpdate: OnModifyForeignAction): AlterTableAddForeignKeyConstraintBuilder;
|
|
14
|
+
toOperationNode(): AlterTableNode;
|
|
15
|
+
compile(): CompiledQuery;
|
|
16
|
+
execute(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface AlterTableAddForeignKeyConstraintBuilderProps {
|
|
19
|
+
readonly queryId: QueryId;
|
|
20
|
+
readonly executor: QueryExecutor;
|
|
21
|
+
readonly node: AlterTableNode;
|
|
22
|
+
readonly constraintBuilder: ForeignKeyConstraintBuilder;
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="./alter-table-add-foreign-key-constraint-builder.d.ts" />
|
|
2
|
+
import { AddConstraintNode } from '../operation-node/add-constraint-node.js';
|
|
3
|
+
import { AlterTableNode } from '../operation-node/alter-table-node.js';
|
|
4
|
+
import { freeze } from '../util/object-utils.js';
|
|
5
|
+
import { preventAwait } from '../util/prevent-await.js';
|
|
6
|
+
export class AlterTableAddForeignKeyConstraintBuilder {
|
|
7
|
+
#props;
|
|
8
|
+
constructor(props) {
|
|
9
|
+
this.#props = freeze(props);
|
|
10
|
+
}
|
|
11
|
+
onDelete(onDelete) {
|
|
12
|
+
return new AlterTableAddForeignKeyConstraintBuilder({
|
|
13
|
+
...this.#props,
|
|
14
|
+
constraintBuilder: this.#props.constraintBuilder.onDelete(onDelete),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
onUpdate(onUpdate) {
|
|
18
|
+
return new AlterTableAddForeignKeyConstraintBuilder({
|
|
19
|
+
...this.#props,
|
|
20
|
+
constraintBuilder: this.#props.constraintBuilder.onUpdate(onUpdate),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
toOperationNode() {
|
|
24
|
+
return this.#props.executor.transformQuery(AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
25
|
+
addConstraint: AddConstraintNode.create(this.#props.constraintBuilder.toOperationNode()),
|
|
26
|
+
}), this.#props.queryId);
|
|
27
|
+
}
|
|
28
|
+
compile() {
|
|
29
|
+
return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
|
|
30
|
+
}
|
|
31
|
+
async execute() {
|
|
32
|
+
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
preventAwait(AlterTableAddForeignKeyConstraintBuilder, "don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { AlterTableNode } from '../operation-node/alter-table-node.js';
|
|
2
2
|
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
3
|
-
import { OnModifyForeignAction } from '../operation-node/references-node.js';
|
|
4
3
|
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
5
4
|
import { Compilable } from '../util/compilable.js';
|
|
6
5
|
import { ColumnDefinitionBuilderCallback } from './column-definition-builder.js';
|
|
7
6
|
import { QueryId } from '../util/query-id.js';
|
|
8
7
|
import { QueryExecutor } from '../query-executor/query-executor.js';
|
|
9
8
|
import { DataTypeExpression } from '../parser/data-type-parser.js';
|
|
10
|
-
import { ForeignKeyConstraintBuilder, ForeignKeyConstraintBuilderInterface } from './foreign-key-constraint-builder.js';
|
|
11
9
|
import { Expression } from '../expression/expression.js';
|
|
12
10
|
import { AlterColumnBuilderCallback } from './alter-column-builder.js';
|
|
11
|
+
import { AlterTableExecutor } from './alter-table-executor.js';
|
|
12
|
+
import { AlterTableAddForeignKeyConstraintBuilder } from './alter-table-add-foreign-key-constraint-builder.js';
|
|
13
|
+
import { AlterTableDropConstraintBuilder } from './alter-table-drop-constraint-builder.js';
|
|
13
14
|
/**
|
|
14
15
|
* This builder can be used to create a `alter table` query.
|
|
15
16
|
*/
|
|
@@ -60,15 +61,6 @@ export interface AlterTableBuilderProps {
|
|
|
60
61
|
readonly executor: QueryExecutor;
|
|
61
62
|
readonly node: AlterTableNode;
|
|
62
63
|
}
|
|
63
|
-
export declare class AlterTableExecutor implements OperationNodeSource, Compilable {
|
|
64
|
-
#private;
|
|
65
|
-
constructor(props: AlterTableExecutorProps);
|
|
66
|
-
toOperationNode(): AlterTableNode;
|
|
67
|
-
compile(): CompiledQuery;
|
|
68
|
-
execute(): Promise<void>;
|
|
69
|
-
}
|
|
70
|
-
export interface AlterTableExecutorProps extends AlterTableBuilderProps {
|
|
71
|
-
}
|
|
72
64
|
export interface ColumnAlteringInterface {
|
|
73
65
|
alterColumn(column: string, alteration: AlterColumnBuilderCallback): ColumnAlteringInterface;
|
|
74
66
|
dropColumn(column: string): ColumnAlteringInterface;
|
|
@@ -106,27 +98,3 @@ export declare class AlterTableColumnAlteringBuilder implements ColumnAlteringIn
|
|
|
106
98
|
}
|
|
107
99
|
export interface AlterTableColumnAlteringBuilderProps extends AlterTableBuilderProps {
|
|
108
100
|
}
|
|
109
|
-
export declare class AlterTableAddForeignKeyConstraintBuilder implements ForeignKeyConstraintBuilderInterface<AlterTableAddForeignKeyConstraintBuilder>, OperationNodeSource, Compilable {
|
|
110
|
-
#private;
|
|
111
|
-
constructor(props: AlterTableAddForeignKeyConstraintBuilderProps);
|
|
112
|
-
onDelete(onDelete: OnModifyForeignAction): AlterTableAddForeignKeyConstraintBuilder;
|
|
113
|
-
onUpdate(onUpdate: OnModifyForeignAction): AlterTableAddForeignKeyConstraintBuilder;
|
|
114
|
-
toOperationNode(): AlterTableNode;
|
|
115
|
-
compile(): CompiledQuery;
|
|
116
|
-
execute(): Promise<void>;
|
|
117
|
-
}
|
|
118
|
-
export interface AlterTableAddForeignKeyConstraintBuilderProps extends AlterTableBuilderProps {
|
|
119
|
-
readonly constraintBuilder: ForeignKeyConstraintBuilder;
|
|
120
|
-
}
|
|
121
|
-
export declare class AlterTableDropConstraintBuilder implements OperationNodeSource, Compilable {
|
|
122
|
-
#private;
|
|
123
|
-
constructor(props: AlterTableDropConstraintBuilderProps);
|
|
124
|
-
ifExists(): AlterTableDropConstraintBuilder;
|
|
125
|
-
cascade(): AlterTableDropConstraintBuilder;
|
|
126
|
-
restrict(): AlterTableDropConstraintBuilder;
|
|
127
|
-
toOperationNode(): AlterTableNode;
|
|
128
|
-
compile(): CompiledQuery;
|
|
129
|
-
execute(): Promise<void>;
|
|
130
|
-
}
|
|
131
|
-
export interface AlterTableDropConstraintBuilderProps extends AlterTableBuilderProps {
|
|
132
|
-
}
|
|
@@ -11,7 +11,7 @@ import { preventAwait } from '../util/prevent-await.js';
|
|
|
11
11
|
import { ColumnDefinitionBuilder, } from './column-definition-builder.js';
|
|
12
12
|
import { ModifyColumnNode } from '../operation-node/modify-column-node.js';
|
|
13
13
|
import { parseDataTypeExpression, } from '../parser/data-type-parser.js';
|
|
14
|
-
import { ForeignKeyConstraintBuilder
|
|
14
|
+
import { ForeignKeyConstraintBuilder } from './foreign-key-constraint-builder.js';
|
|
15
15
|
import { AddConstraintNode } from '../operation-node/add-constraint-node.js';
|
|
16
16
|
import { UniqueConstraintNode } from '../operation-node/unique-constraint-node.js';
|
|
17
17
|
import { CheckConstraintNode } from '../operation-node/check-constraint-node.js';
|
|
@@ -20,6 +20,9 @@ import { ColumnNode } from '../operation-node/column-node.js';
|
|
|
20
20
|
import { parseTable } from '../parser/table-parser.js';
|
|
21
21
|
import { DropConstraintNode } from '../operation-node/drop-constraint-node.js';
|
|
22
22
|
import { AlterColumnBuilder, } from './alter-column-builder.js';
|
|
23
|
+
import { AlterTableExecutor } from './alter-table-executor.js';
|
|
24
|
+
import { AlterTableAddForeignKeyConstraintBuilder } from './alter-table-add-foreign-key-constraint-builder.js';
|
|
25
|
+
import { AlterTableDropConstraintBuilder } from './alter-table-drop-constraint-builder.js';
|
|
23
26
|
/**
|
|
24
27
|
* This builder can be used to create a `alter table` query.
|
|
25
28
|
*/
|
|
@@ -129,21 +132,6 @@ export class AlterTableBuilder {
|
|
|
129
132
|
return func(this);
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
|
-
export class AlterTableExecutor {
|
|
133
|
-
#props;
|
|
134
|
-
constructor(props) {
|
|
135
|
-
this.#props = freeze(props);
|
|
136
|
-
}
|
|
137
|
-
toOperationNode() {
|
|
138
|
-
return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
|
|
139
|
-
}
|
|
140
|
-
compile() {
|
|
141
|
-
return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
|
|
142
|
-
}
|
|
143
|
-
async execute() {
|
|
144
|
-
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
135
|
export class AlterTableColumnAlteringBuilder {
|
|
148
136
|
#props;
|
|
149
137
|
constructor(props) {
|
|
@@ -192,83 +180,6 @@ export class AlterTableColumnAlteringBuilder {
|
|
|
192
180
|
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
|
|
193
181
|
}
|
|
194
182
|
}
|
|
195
|
-
export class AlterTableAddForeignKeyConstraintBuilder {
|
|
196
|
-
#props;
|
|
197
|
-
constructor(props) {
|
|
198
|
-
this.#props = freeze(props);
|
|
199
|
-
}
|
|
200
|
-
onDelete(onDelete) {
|
|
201
|
-
return new AlterTableAddForeignKeyConstraintBuilder({
|
|
202
|
-
...this.#props,
|
|
203
|
-
constraintBuilder: this.#props.constraintBuilder.onDelete(onDelete),
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
onUpdate(onUpdate) {
|
|
207
|
-
return new AlterTableAddForeignKeyConstraintBuilder({
|
|
208
|
-
...this.#props,
|
|
209
|
-
constraintBuilder: this.#props.constraintBuilder.onUpdate(onUpdate),
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
toOperationNode() {
|
|
213
|
-
return this.#props.executor.transformQuery(AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
214
|
-
addConstraint: AddConstraintNode.create(this.#props.constraintBuilder.toOperationNode()),
|
|
215
|
-
}), this.#props.queryId);
|
|
216
|
-
}
|
|
217
|
-
compile() {
|
|
218
|
-
return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
|
|
219
|
-
}
|
|
220
|
-
async execute() {
|
|
221
|
-
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
export class AlterTableDropConstraintBuilder {
|
|
225
|
-
#props;
|
|
226
|
-
constructor(props) {
|
|
227
|
-
this.#props = freeze(props);
|
|
228
|
-
}
|
|
229
|
-
ifExists() {
|
|
230
|
-
return new AlterTableDropConstraintBuilder({
|
|
231
|
-
...this.#props,
|
|
232
|
-
node: AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
233
|
-
dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
|
|
234
|
-
ifExists: true,
|
|
235
|
-
}),
|
|
236
|
-
}),
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
cascade() {
|
|
240
|
-
return new AlterTableDropConstraintBuilder({
|
|
241
|
-
...this.#props,
|
|
242
|
-
node: AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
243
|
-
dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
|
|
244
|
-
modifier: 'cascade',
|
|
245
|
-
}),
|
|
246
|
-
}),
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
restrict() {
|
|
250
|
-
return new AlterTableDropConstraintBuilder({
|
|
251
|
-
...this.#props,
|
|
252
|
-
node: AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
253
|
-
dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
|
|
254
|
-
modifier: 'restrict',
|
|
255
|
-
}),
|
|
256
|
-
}),
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
toOperationNode() {
|
|
260
|
-
return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
|
|
261
|
-
}
|
|
262
|
-
compile() {
|
|
263
|
-
return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
|
|
264
|
-
}
|
|
265
|
-
async execute() {
|
|
266
|
-
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
183
|
preventAwait(AlterTableBuilder, "don't await AlterTableBuilder instances");
|
|
270
184
|
preventAwait(AlterColumnBuilder, "don't await AlterColumnBuilder instances");
|
|
271
|
-
preventAwait(AlterTableExecutor, "don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");
|
|
272
185
|
preventAwait(AlterTableColumnAlteringBuilder, "don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");
|
|
273
|
-
preventAwait(AlterTableAddForeignKeyConstraintBuilder, "don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");
|
|
274
|
-
preventAwait(AlterTableDropConstraintBuilder, "don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AlterTableNode } from '../operation-node/alter-table-node.js';
|
|
2
|
+
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
3
|
+
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
4
|
+
import { QueryExecutor } from '../query-executor/query-executor.js';
|
|
5
|
+
import { Compilable } from '../util/compilable.js';
|
|
6
|
+
import { QueryId } from '../util/query-id.js';
|
|
7
|
+
export declare class AlterTableDropConstraintBuilder implements OperationNodeSource, Compilable {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(props: AlterTableDropConstraintBuilderProps);
|
|
10
|
+
ifExists(): AlterTableDropConstraintBuilder;
|
|
11
|
+
cascade(): AlterTableDropConstraintBuilder;
|
|
12
|
+
restrict(): AlterTableDropConstraintBuilder;
|
|
13
|
+
toOperationNode(): AlterTableNode;
|
|
14
|
+
compile(): CompiledQuery;
|
|
15
|
+
execute(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface AlterTableDropConstraintBuilderProps {
|
|
18
|
+
readonly queryId: QueryId;
|
|
19
|
+
readonly executor: QueryExecutor;
|
|
20
|
+
readonly node: AlterTableNode;
|
|
21
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="./alter-table-drop-constraint-builder.d.ts" />
|
|
2
|
+
import { AlterTableNode } from '../operation-node/alter-table-node.js';
|
|
3
|
+
import { DropConstraintNode } from '../operation-node/drop-constraint-node.js';
|
|
4
|
+
import { freeze } from '../util/object-utils.js';
|
|
5
|
+
import { preventAwait } from '../util/prevent-await.js';
|
|
6
|
+
export class AlterTableDropConstraintBuilder {
|
|
7
|
+
#props;
|
|
8
|
+
constructor(props) {
|
|
9
|
+
this.#props = freeze(props);
|
|
10
|
+
}
|
|
11
|
+
ifExists() {
|
|
12
|
+
return new AlterTableDropConstraintBuilder({
|
|
13
|
+
...this.#props,
|
|
14
|
+
node: AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
15
|
+
dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
|
|
16
|
+
ifExists: true,
|
|
17
|
+
}),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
cascade() {
|
|
22
|
+
return new AlterTableDropConstraintBuilder({
|
|
23
|
+
...this.#props,
|
|
24
|
+
node: AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
25
|
+
dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
|
|
26
|
+
modifier: 'cascade',
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
restrict() {
|
|
32
|
+
return new AlterTableDropConstraintBuilder({
|
|
33
|
+
...this.#props,
|
|
34
|
+
node: AlterTableNode.cloneWithTableProps(this.#props.node, {
|
|
35
|
+
dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
|
|
36
|
+
modifier: 'restrict',
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
toOperationNode() {
|
|
42
|
+
return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
|
|
43
|
+
}
|
|
44
|
+
compile() {
|
|
45
|
+
return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
|
|
46
|
+
}
|
|
47
|
+
async execute() {
|
|
48
|
+
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
preventAwait(AlterTableDropConstraintBuilder, "don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AlterTableNode } from '../operation-node/alter-table-node.js';
|
|
2
|
+
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
3
|
+
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
4
|
+
import { QueryExecutor } from '../query-executor/query-executor.js';
|
|
5
|
+
import { Compilable } from '../util/compilable.js';
|
|
6
|
+
import { QueryId } from '../util/query-id.js';
|
|
7
|
+
export declare class AlterTableExecutor implements OperationNodeSource, Compilable {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(props: AlterTableExecutorProps);
|
|
10
|
+
toOperationNode(): AlterTableNode;
|
|
11
|
+
compile(): CompiledQuery;
|
|
12
|
+
execute(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface AlterTableExecutorProps {
|
|
15
|
+
readonly queryId: QueryId;
|
|
16
|
+
readonly executor: QueryExecutor;
|
|
17
|
+
readonly node: AlterTableNode;
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="./alter-table-executor.d.ts" />
|
|
2
|
+
import { freeze } from '../util/object-utils.js';
|
|
3
|
+
import { preventAwait } from '../util/prevent-await.js';
|
|
4
|
+
export class AlterTableExecutor {
|
|
5
|
+
#props;
|
|
6
|
+
constructor(props) {
|
|
7
|
+
this.#props = freeze(props);
|
|
8
|
+
}
|
|
9
|
+
toOperationNode() {
|
|
10
|
+
return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
|
|
11
|
+
}
|
|
12
|
+
compile() {
|
|
13
|
+
return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
|
|
14
|
+
}
|
|
15
|
+
async execute() {
|
|
16
|
+
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
preventAwait(AlterTableExecutor, "don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kysely",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.3",
|
|
4
4
|
"description": "Type safe SQL query builder",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test:typings": "tsd test/typings",
|
|
29
29
|
"test:esmimports": "node scripts/check-esm-imports.js",
|
|
30
30
|
"test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
|
|
31
|
-
"prettier": "prettier --write src/**/*.ts test/**/*.ts",
|
|
31
|
+
"prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
|
|
32
32
|
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run script:module-fixup && npm run script:copy-interface-doc",
|
|
33
33
|
"build:esm": "tsc -p tsconfig.json && npm run script:add-deno-type-references",
|
|
34
34
|
"build:cjs": "tsc -p tsconfig-cjs.json",
|