kysely 0.19.12 → 0.21.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 +1 -1
- package/dist/cjs/dialect/mysql/mysql-introspector.js +2 -0
- package/dist/cjs/dialect/mysql/mysql-query-compiler.d.ts +5 -0
- package/dist/cjs/dialect/mysql/mysql-query-compiler.js +16 -0
- package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +5 -12
- package/dist/cjs/dialect/postgres/postgres-driver.js +16 -11
- package/dist/cjs/dialect/postgres/postgres-introspector.js +17 -9
- package/dist/cjs/dialect/postgres/postgres-query-compiler.d.ts +1 -3
- package/dist/cjs/dialect/postgres/postgres-query-compiler.js +3 -8
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +2 -0
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.d.ts +3 -0
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.js +10 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/operation-node/create-table-node.d.ts +6 -1
- package/dist/cjs/operation-node/create-table-node.js +16 -0
- package/dist/cjs/operation-node/create-type-node.d.ts +2 -2
- package/dist/cjs/operation-node/create-type-node.js +2 -2
- package/dist/cjs/operation-node/create-view-node.d.ts +2 -2
- package/dist/cjs/operation-node/create-view-node.js +2 -2
- package/dist/cjs/operation-node/delete-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/delete-query-node.js +6 -0
- package/dist/cjs/operation-node/drop-index-node.d.ts +2 -2
- package/dist/cjs/operation-node/drop-index-node.js +2 -2
- package/dist/cjs/operation-node/drop-type-node.d.ts +2 -2
- package/dist/cjs/operation-node/drop-type-node.js +2 -2
- package/dist/cjs/operation-node/drop-view-node.d.ts +2 -2
- package/dist/cjs/operation-node/drop-view-node.js +2 -2
- package/dist/cjs/operation-node/explain-node.d.ts +16 -0
- package/dist/cjs/operation-node/explain-node.js +19 -0
- package/dist/cjs/operation-node/identifier-node.d.ts +2 -2
- package/dist/cjs/operation-node/identifier-node.js +2 -2
- package/dist/cjs/operation-node/insert-query-node.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +7 -3
- package/dist/cjs/operation-node/operation-node-transformer.js +30 -6
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +8 -4
- package/dist/cjs/operation-node/operation-node-visitor.js +2 -0
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/reference-node.d.ts +1 -1
- package/dist/cjs/operation-node/reference-node.js +1 -2
- package/dist/cjs/operation-node/schemable-identifier-node.d.ts +15 -0
- package/dist/cjs/operation-node/schemable-identifier-node.js +26 -0
- package/dist/cjs/operation-node/select-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/select-query-node.js +6 -0
- package/dist/cjs/operation-node/selection-node.d.ts +2 -1
- package/dist/cjs/operation-node/table-node.d.ts +2 -3
- package/dist/cjs/operation-node/table-node.js +3 -4
- package/dist/cjs/operation-node/update-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/update-query-node.js +6 -0
- package/dist/cjs/parser/select-parser.js +2 -1
- package/dist/cjs/plugin/camel-case/camel-case-transformer.js +1 -1
- package/dist/cjs/plugin/with-schema/with-schema-transformer.d.ts +4 -28
- package/dist/cjs/plugin/with-schema/with-schema-transformer.js +72 -78
- package/dist/cjs/query-builder/delete-query-builder.d.ts +19 -1
- package/dist/cjs/query-builder/delete-query-builder.js +24 -0
- package/dist/cjs/query-builder/function-builder.d.ts +3 -3
- package/dist/cjs/query-builder/insert-query-builder.d.ts +20 -2
- package/dist/cjs/query-builder/insert-query-builder.js +26 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +38 -1
- package/dist/cjs/query-builder/select-query-builder.js +45 -2
- package/dist/cjs/query-builder/update-query-builder.d.ts +20 -1
- package/dist/cjs/query-builder/update-query-builder.js +25 -0
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +8 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +63 -5
- package/dist/cjs/raw-builder/sql.d.ts +96 -96
- package/dist/cjs/raw-builder/sql.js +0 -96
- package/dist/cjs/schema/alter-table-builder.d.ts +6 -6
- package/dist/cjs/schema/column-definition-builder.d.ts +6 -6
- package/dist/cjs/schema/create-table-builder.d.ts +54 -0
- package/dist/cjs/schema/create-table-builder.js +64 -0
- package/dist/cjs/util/explainable.d.ts +5 -0
- package/dist/cjs/util/explainable.js +2 -0
- package/dist/esm/dialect/mysql/mysql-introspector.js +2 -0
- package/dist/esm/dialect/mysql/mysql-query-compiler.d.ts +5 -0
- package/dist/esm/dialect/mysql/mysql-query-compiler.js +16 -0
- package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +5 -12
- package/dist/esm/dialect/postgres/postgres-driver.js +16 -11
- package/dist/esm/dialect/postgres/postgres-introspector.js +17 -9
- package/dist/esm/dialect/postgres/postgres-query-compiler.d.ts +1 -3
- package/dist/esm/dialect/postgres/postgres-query-compiler.js +3 -8
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +2 -0
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.d.ts +3 -0
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +10 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/operation-node/create-table-node.d.ts +6 -1
- package/dist/esm/operation-node/create-table-node.js +16 -0
- package/dist/esm/operation-node/create-type-node.d.ts +2 -2
- package/dist/esm/operation-node/create-type-node.js +2 -2
- package/dist/esm/operation-node/create-view-node.d.ts +2 -2
- package/dist/esm/operation-node/create-view-node.js +2 -2
- package/dist/esm/operation-node/delete-query-node.d.ts +3 -0
- package/dist/esm/operation-node/delete-query-node.js +6 -0
- package/dist/esm/operation-node/drop-index-node.d.ts +2 -2
- package/dist/esm/operation-node/drop-index-node.js +2 -2
- package/dist/esm/operation-node/drop-type-node.d.ts +2 -2
- package/dist/esm/operation-node/drop-type-node.js +2 -2
- package/dist/esm/operation-node/drop-view-node.d.ts +2 -2
- package/dist/esm/operation-node/drop-view-node.js +2 -2
- package/dist/esm/operation-node/explain-node.d.ts +16 -0
- package/dist/esm/operation-node/explain-node.js +17 -0
- package/dist/esm/operation-node/identifier-node.d.ts +2 -2
- package/dist/esm/operation-node/identifier-node.js +2 -2
- package/dist/esm/operation-node/insert-query-node.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-transformer.d.ts +7 -3
- package/dist/esm/operation-node/operation-node-transformer.js +30 -6
- package/dist/esm/operation-node/operation-node-visitor.d.ts +8 -4
- package/dist/esm/operation-node/operation-node-visitor.js +2 -0
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/reference-node.d.ts +1 -1
- package/dist/esm/operation-node/reference-node.js +1 -2
- package/dist/esm/operation-node/schemable-identifier-node.d.ts +15 -0
- package/dist/esm/operation-node/schemable-identifier-node.js +24 -0
- package/dist/esm/operation-node/select-query-node.d.ts +3 -0
- package/dist/esm/operation-node/select-query-node.js +6 -0
- package/dist/esm/operation-node/selection-node.d.ts +2 -1
- package/dist/esm/operation-node/table-node.d.ts +2 -3
- package/dist/esm/operation-node/table-node.js +3 -4
- package/dist/esm/operation-node/update-query-node.d.ts +3 -0
- package/dist/esm/operation-node/update-query-node.js +6 -0
- package/dist/esm/parser/select-parser.js +2 -1
- package/dist/esm/plugin/camel-case/camel-case-transformer.js +1 -1
- package/dist/esm/plugin/with-schema/with-schema-transformer.d.ts +4 -28
- package/dist/esm/plugin/with-schema/with-schema-transformer.js +72 -78
- package/dist/esm/query-builder/delete-query-builder.d.ts +19 -1
- package/dist/esm/query-builder/delete-query-builder.js +24 -0
- package/dist/esm/query-builder/function-builder.d.ts +3 -3
- package/dist/esm/query-builder/insert-query-builder.d.ts +20 -2
- package/dist/esm/query-builder/insert-query-builder.js +26 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +38 -1
- package/dist/esm/query-builder/select-query-builder.js +45 -2
- package/dist/esm/query-builder/update-query-builder.d.ts +20 -1
- package/dist/esm/query-builder/update-query-builder.js +25 -0
- package/dist/esm/query-compiler/default-query-compiler.d.ts +8 -0
- package/dist/esm/query-compiler/default-query-compiler.js +63 -5
- package/dist/esm/raw-builder/sql.d.ts +96 -96
- package/dist/esm/raw-builder/sql.js +0 -96
- package/dist/esm/schema/alter-table-builder.d.ts +6 -6
- package/dist/esm/schema/column-definition-builder.d.ts +6 -6
- package/dist/esm/schema/create-table-builder.d.ts +54 -0
- package/dist/esm/schema/create-table-builder.js +64 -0
- package/dist/esm/util/explainable.d.ts +5 -0
- package/dist/esm/util/explainable.js +2 -0
- package/package.json +4 -1
|
@@ -32,6 +32,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
32
32
|
!insert_query_node_js_1.InsertQueryNode.is(this.parentNode) &&
|
|
33
33
|
!create_view_node_js_1.CreateViewNode.is(this.parentNode) &&
|
|
34
34
|
!union_node_js_1.UnionNode.is(this.parentNode);
|
|
35
|
+
if (this.parentNode === undefined && node.explain) {
|
|
36
|
+
this.visitNode(node.explain);
|
|
37
|
+
this.append(' ');
|
|
38
|
+
}
|
|
35
39
|
if (wrapInParens) {
|
|
36
40
|
this.append('(');
|
|
37
41
|
}
|
|
@@ -127,6 +131,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
127
131
|
}
|
|
128
132
|
visitInsertQuery(node) {
|
|
129
133
|
const isSubQuery = this.nodeStack.find(query_node_js_1.QueryNode.is) !== node;
|
|
134
|
+
if (!isSubQuery && node.explain) {
|
|
135
|
+
this.visitNode(node.explain);
|
|
136
|
+
this.append(' ');
|
|
137
|
+
}
|
|
130
138
|
if (isSubQuery) {
|
|
131
139
|
this.append('(');
|
|
132
140
|
}
|
|
@@ -171,6 +179,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
171
179
|
}
|
|
172
180
|
visitDeleteQuery(node) {
|
|
173
181
|
const isSubQuery = this.nodeStack.find(query_node_js_1.QueryNode.is) !== node;
|
|
182
|
+
if (!isSubQuery && node.explain) {
|
|
183
|
+
this.visitNode(node.explain);
|
|
184
|
+
this.append(' ');
|
|
185
|
+
}
|
|
174
186
|
if (isSubQuery) {
|
|
175
187
|
this.append('(');
|
|
176
188
|
}
|
|
@@ -227,7 +239,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
227
239
|
this.append(this.getRightIdentifierWrapper());
|
|
228
240
|
}
|
|
229
241
|
compileUnwrappedIdentifier(node) {
|
|
230
|
-
|
|
242
|
+
if (!(0, object_utils_js_1.isString)(node.name)) {
|
|
243
|
+
throw new Error('a non-string identifier was passed to compileUnwrappedIdentifier.');
|
|
244
|
+
}
|
|
245
|
+
this.append(this.sanitizeIdentifier(node.name));
|
|
231
246
|
}
|
|
232
247
|
visitFilter(node) {
|
|
233
248
|
if (node.left) {
|
|
@@ -303,14 +318,21 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
303
318
|
this.append(node.operator);
|
|
304
319
|
}
|
|
305
320
|
visitTable(node) {
|
|
321
|
+
this.visitNode(node.table);
|
|
322
|
+
}
|
|
323
|
+
visitSchemableIdentifier(node) {
|
|
306
324
|
if (node.schema) {
|
|
307
325
|
this.visitNode(node.schema);
|
|
308
326
|
this.append('.');
|
|
309
327
|
}
|
|
310
|
-
this.visitNode(node.
|
|
328
|
+
this.visitNode(node.identifier);
|
|
311
329
|
}
|
|
312
330
|
visitCreateTable(node) {
|
|
313
331
|
this.append('create ');
|
|
332
|
+
if (node.frontModifiers) {
|
|
333
|
+
this.compileList(node.frontModifiers, ' ');
|
|
334
|
+
this.append(' ');
|
|
335
|
+
}
|
|
314
336
|
if (node.temporary) {
|
|
315
337
|
this.append('temporary ');
|
|
316
338
|
}
|
|
@@ -326,6 +348,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
326
348
|
this.append(' on commit ');
|
|
327
349
|
this.append(node.onCommit);
|
|
328
350
|
}
|
|
351
|
+
if (node.endModifiers) {
|
|
352
|
+
this.append(' ');
|
|
353
|
+
this.compileList(node.endModifiers, ' ');
|
|
354
|
+
}
|
|
329
355
|
}
|
|
330
356
|
visitColumnDefinition(node) {
|
|
331
357
|
this.visitNode(node.column);
|
|
@@ -412,6 +438,10 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
412
438
|
}
|
|
413
439
|
visitUpdateQuery(node) {
|
|
414
440
|
const isSubQuery = this.nodeStack.find(query_node_js_1.QueryNode.is) !== node;
|
|
441
|
+
if (!isSubQuery && node.explain) {
|
|
442
|
+
this.visitNode(node.explain);
|
|
443
|
+
this.append(' ');
|
|
444
|
+
}
|
|
415
445
|
if (isSubQuery) {
|
|
416
446
|
this.append('(');
|
|
417
447
|
}
|
|
@@ -806,6 +836,25 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
806
836
|
}
|
|
807
837
|
this.visitNode(node.name);
|
|
808
838
|
}
|
|
839
|
+
visitExplain(node) {
|
|
840
|
+
this.append('explain');
|
|
841
|
+
if (node.options || node.format) {
|
|
842
|
+
this.append(' ');
|
|
843
|
+
this.append(this.getLeftExplainOptionsWrapper());
|
|
844
|
+
if (node.options) {
|
|
845
|
+
this.visitNode(node.options);
|
|
846
|
+
if (node.format) {
|
|
847
|
+
this.append(this.getExplainOptionsDelimiter());
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (node.format) {
|
|
851
|
+
this.append('format');
|
|
852
|
+
this.append(this.getExplainOptionAssignment());
|
|
853
|
+
this.append(node.format);
|
|
854
|
+
}
|
|
855
|
+
this.append(this.getRightExplainOptionsWrapper());
|
|
856
|
+
}
|
|
857
|
+
}
|
|
809
858
|
append(str) {
|
|
810
859
|
this.#sql += str;
|
|
811
860
|
}
|
|
@@ -822,10 +871,19 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
|
|
|
822
871
|
getCurrentParameterPlaceholder() {
|
|
823
872
|
return '$' + this.numParameters;
|
|
824
873
|
}
|
|
874
|
+
getLeftExplainOptionsWrapper() {
|
|
875
|
+
return '(';
|
|
876
|
+
}
|
|
877
|
+
getExplainOptionAssignment() {
|
|
878
|
+
return ' ';
|
|
879
|
+
}
|
|
880
|
+
getExplainOptionsDelimiter() {
|
|
881
|
+
return ', ';
|
|
882
|
+
}
|
|
883
|
+
getRightExplainOptionsWrapper() {
|
|
884
|
+
return ')';
|
|
885
|
+
}
|
|
825
886
|
sanitizeIdentifier(identifier) {
|
|
826
|
-
if (!(0, object_utils_js_1.isString)(identifier)) {
|
|
827
|
-
throw new Error('a non-string identifier was passed to sanitizeIdentifier.');
|
|
828
|
-
}
|
|
829
887
|
const leftWrap = this.getLeftIdentifierWrapper();
|
|
830
888
|
const rightWrap = this.getRightIdentifierWrapper();
|
|
831
889
|
let sanitized = '';
|
|
@@ -1,5 +1,101 @@
|
|
|
1
1
|
import { RawBuilder } from './raw-builder.js';
|
|
2
2
|
export interface Sql {
|
|
3
|
+
/**
|
|
4
|
+
* Template tag for creating raw SQL snippets and queries.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { sql } from 'kysely'
|
|
8
|
+
*
|
|
9
|
+
* const id = 123
|
|
10
|
+
*
|
|
11
|
+
* const snippet = sql<Person[]>`select * from person where id = ${id}`
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Substitutions (the things inside `${}`) are automatically passed to the database
|
|
15
|
+
* as parameters and are NOT interpolated to the SQL string. There's no need to worry
|
|
16
|
+
* about SQL injection vulnerabilities.
|
|
17
|
+
*
|
|
18
|
+
* If you need your substitutions to be interpreted as identifiers, value literals or
|
|
19
|
+
* lists of things, see the {@link Sql.ref}, {@link Sql.table}, {@link Sql.id},
|
|
20
|
+
* {@link Sql.literal}, {@link Sql.raw} and {@link Sql.join} functions.
|
|
21
|
+
*
|
|
22
|
+
* You can pass sql snippets returned by the `sql` tag pretty much anywhere. Whenever
|
|
23
|
+
* something can't be done using the Kysely API, you should be able to drop down to
|
|
24
|
+
* raw SQL using the `sql` tag. Here's an example query that uses raw sql in a bunch
|
|
25
|
+
* of methods:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* const persons = await db
|
|
29
|
+
* .selectFrom('person')
|
|
30
|
+
* .select(
|
|
31
|
+
* // If you use `sql` in a select statement, remember to call the `as`
|
|
32
|
+
* // method to give it an alias. Otherwise Kysely is not able to add
|
|
33
|
+
* // the column to the result type.
|
|
34
|
+
* sql<string>`concat(first_name, ' ', last_name)`.as('full_name')
|
|
35
|
+
* )
|
|
36
|
+
* .where(sql`birthdate between ${date1} and ${date2}`)
|
|
37
|
+
* // Here we assume we have list of nicknames for the person
|
|
38
|
+
* // (a list of strings) and we use the PostgreSQL `@>` operator
|
|
39
|
+
* // to test if all of them are valid nicknames for the user.
|
|
40
|
+
* .where('nicknames', '@>', sql`ARRAY[${sql.join(nicknames)}]`)
|
|
41
|
+
* .orderBy(sql`concat(first_name, ' ', last_name)`)
|
|
42
|
+
* .execute()
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* The generated SQL (PostgreSQL):
|
|
46
|
+
*
|
|
47
|
+
* ```sql
|
|
48
|
+
* select concat(first_name, ' ', last_name) as "full_name"
|
|
49
|
+
* from "person"
|
|
50
|
+
* where birthdate between $1 and $2
|
|
51
|
+
* and "nicknames" @> ARRAY[$3, $4, $5, $6, $7, $8, $9, $10]
|
|
52
|
+
* order by concat(first_name, ' ', last_name)
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* SQL snippets can be executed by calling the `execute` method and passing a `Kysely`
|
|
56
|
+
* instance as the only argument:
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* const result = await sql<Person[]>`select * from person`.execute(db)
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* You can merge other `sql` expressions and queries using substitutions:
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* const petName = db.selectFrom('pet').select('name').limit(1)
|
|
66
|
+
* const fullName = sql`concat(first_name, ' ', last_name)`
|
|
67
|
+
*
|
|
68
|
+
* sql`
|
|
69
|
+
* select ${fullName} as full_name, ${petName} as pet_name
|
|
70
|
+
* from person
|
|
71
|
+
* `
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* Substitutions also handle {@link ExpressionBuilder.ref},
|
|
75
|
+
* {@link DynamicModule.ref} and pretty much anything else you
|
|
76
|
+
* throw at it. Here's an example of calling a function in a
|
|
77
|
+
* type-safe way:
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* db.selectFrom('person')
|
|
81
|
+
* .select([
|
|
82
|
+
* 'first_name',
|
|
83
|
+
* 'last_name',
|
|
84
|
+
* (eb) => {
|
|
85
|
+
* // The `eb.ref` method is type-safe and only accepts
|
|
86
|
+
* // column references that are possible.
|
|
87
|
+
* const firstName = eb.ref('first_name')
|
|
88
|
+
* const lastName = eb.ref('last_name')
|
|
89
|
+
*
|
|
90
|
+
* const fullName = sql<string>`concat(${firstName}, ' ', ${lastName})`
|
|
91
|
+
* return fullName.as('full_name')
|
|
92
|
+
* }
|
|
93
|
+
* ])
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* don't know if that amount of ceremony is worth the small increase in
|
|
97
|
+
* type-safety though... But it's possible.
|
|
98
|
+
*/
|
|
3
99
|
<T = unknown>(sqlFragments: TemplateStringsArray, ...parameters: unknown[]): RawBuilder<T>;
|
|
4
100
|
/**
|
|
5
101
|
* This can be used to add runtime column references to SQL snippets.
|
|
@@ -232,100 +328,4 @@ export interface Sql {
|
|
|
232
328
|
*/
|
|
233
329
|
join(array: unknown[], separator?: RawBuilder<any>): RawBuilder<unknown>;
|
|
234
330
|
}
|
|
235
|
-
/**
|
|
236
|
-
* Template tag for creating raw SQL snippets and queries.
|
|
237
|
-
*
|
|
238
|
-
* ```ts
|
|
239
|
-
* import { sql } from 'kysely'
|
|
240
|
-
*
|
|
241
|
-
* const id = 123
|
|
242
|
-
*
|
|
243
|
-
* const snippet = sql<Person[]>`select * from person where id = ${id}`
|
|
244
|
-
* ```
|
|
245
|
-
*
|
|
246
|
-
* Substitutions (the things inside `${}`) are automatically passed to the database
|
|
247
|
-
* as parameters and are NOT interpolated to the SQL string. There's no need to worry
|
|
248
|
-
* about SQL injection vulnerabilities.
|
|
249
|
-
*
|
|
250
|
-
* If you need your substitutions to be interpreted as identifiers, value literals or
|
|
251
|
-
* lists of things, see the {@link Sql.ref}, {@link Sql.table}, {@link Sql.id},
|
|
252
|
-
* {@link Sql.literal}, {@link Sql.raw} and {@link Sql.join} functions.
|
|
253
|
-
*
|
|
254
|
-
* You can pass sql snippets returned by the `sql` tag pretty much anywhere. Whenever
|
|
255
|
-
* something can't be done using the Kysely API, you should be able to drop down to
|
|
256
|
-
* raw SQL using the `sql` tag. Here's an example query that uses raw sql in a bunch
|
|
257
|
-
* of methods:
|
|
258
|
-
*
|
|
259
|
-
* ```ts
|
|
260
|
-
* const persons = await db
|
|
261
|
-
* .selectFrom('person')
|
|
262
|
-
* .select(
|
|
263
|
-
* // If you use `sql` in a select statement, remember to call the `as`
|
|
264
|
-
* // method to give it an alias. Otherwise Kysely is not able to add
|
|
265
|
-
* // the column to the result type.
|
|
266
|
-
* sql<string>`concat(first_name, ' ', last_name)`.as('full_name')
|
|
267
|
-
* )
|
|
268
|
-
* .where(sql`birthdate between ${date1} and ${date2}`)
|
|
269
|
-
* // Here we assume we have list of nicknames for the person
|
|
270
|
-
* // (a list of strings) and we use the PostgreSQL `@>` operator
|
|
271
|
-
* // to test if all of them are valid nicknames for the user.
|
|
272
|
-
* .where('nicknames', '@>', sql`ARRAY[${sql.join(nicknames)}]`)
|
|
273
|
-
* .orderBy(sql`concat(first_name, ' ', last_name)`)
|
|
274
|
-
* .execute()
|
|
275
|
-
* ```
|
|
276
|
-
*
|
|
277
|
-
* The generated SQL (PostgreSQL):
|
|
278
|
-
*
|
|
279
|
-
* ```sql
|
|
280
|
-
* select concat(first_name, ' ', last_name) as "full_name"
|
|
281
|
-
* from "person"
|
|
282
|
-
* where birthdate between $1 and $2
|
|
283
|
-
* and "nicknames" @> ARRAY[$3, $4, $5, $6, $7, $8, $9, $10]
|
|
284
|
-
* order by concat(first_name, ' ', last_name)
|
|
285
|
-
* ```
|
|
286
|
-
*
|
|
287
|
-
* SQL snippets can be executed by calling the `execute` method and passing a `Kysely`
|
|
288
|
-
* instance as the only argument:
|
|
289
|
-
*
|
|
290
|
-
* ```ts
|
|
291
|
-
* const result = await sql<Person[]>`select * from person`.execute(db)
|
|
292
|
-
* ```
|
|
293
|
-
*
|
|
294
|
-
* You can merge other `sql` expressions and queries using substitutions:
|
|
295
|
-
*
|
|
296
|
-
* ```ts
|
|
297
|
-
* const petName = db.selectFrom('pet').select('name').limit(1)
|
|
298
|
-
* const fullName = sql`concat(first_name, ' ', last_name)`
|
|
299
|
-
*
|
|
300
|
-
* sql`
|
|
301
|
-
* select ${fullName} as full_name, ${petName} as pet_name
|
|
302
|
-
* from person
|
|
303
|
-
* `
|
|
304
|
-
* ```
|
|
305
|
-
*
|
|
306
|
-
* Substitutions also handle {@link ExpressionBuilder.ref},
|
|
307
|
-
* {@link DynamicModule.ref} and pretty much anything else you
|
|
308
|
-
* throw at it. Here's an example of calling a function in a
|
|
309
|
-
* type-safe way:
|
|
310
|
-
*
|
|
311
|
-
* ```ts
|
|
312
|
-
* db.selectFrom('person')
|
|
313
|
-
* .select([
|
|
314
|
-
* 'first_name',
|
|
315
|
-
* 'last_name',
|
|
316
|
-
* (eb) => {
|
|
317
|
-
* // The `eb.ref` method is type-safe and only accepts
|
|
318
|
-
* // column references that are possible.
|
|
319
|
-
* const firstName = eb.ref('first_name')
|
|
320
|
-
* const lastName = eb.ref('last_name')
|
|
321
|
-
*
|
|
322
|
-
* const fullName = sql<string>`concat(${firstName}, ' ', ${lastName})`
|
|
323
|
-
* return fullName.as('full_name')
|
|
324
|
-
* }
|
|
325
|
-
* ])
|
|
326
|
-
* ```
|
|
327
|
-
*
|
|
328
|
-
* don't know if that amount of ceremony is worth the small increase in
|
|
329
|
-
* type-safety though... But it's possible.
|
|
330
|
-
*/
|
|
331
331
|
export declare const sql: Sql;
|
|
@@ -9,102 +9,6 @@ const table_parser_js_1 = require("../parser/table-parser.js");
|
|
|
9
9
|
const value_parser_js_1 = require("../parser/value-parser.js");
|
|
10
10
|
const query_id_js_1 = require("../util/query-id.js");
|
|
11
11
|
const raw_builder_js_1 = require("./raw-builder.js");
|
|
12
|
-
/**
|
|
13
|
-
* Template tag for creating raw SQL snippets and queries.
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { sql } from 'kysely'
|
|
17
|
-
*
|
|
18
|
-
* const id = 123
|
|
19
|
-
*
|
|
20
|
-
* const snippet = sql<Person[]>`select * from person where id = ${id}`
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* Substitutions (the things inside `${}`) are automatically passed to the database
|
|
24
|
-
* as parameters and are NOT interpolated to the SQL string. There's no need to worry
|
|
25
|
-
* about SQL injection vulnerabilities.
|
|
26
|
-
*
|
|
27
|
-
* If you need your substitutions to be interpreted as identifiers, value literals or
|
|
28
|
-
* lists of things, see the {@link Sql.ref}, {@link Sql.table}, {@link Sql.id},
|
|
29
|
-
* {@link Sql.literal}, {@link Sql.raw} and {@link Sql.join} functions.
|
|
30
|
-
*
|
|
31
|
-
* You can pass sql snippets returned by the `sql` tag pretty much anywhere. Whenever
|
|
32
|
-
* something can't be done using the Kysely API, you should be able to drop down to
|
|
33
|
-
* raw SQL using the `sql` tag. Here's an example query that uses raw sql in a bunch
|
|
34
|
-
* of methods:
|
|
35
|
-
*
|
|
36
|
-
* ```ts
|
|
37
|
-
* const persons = await db
|
|
38
|
-
* .selectFrom('person')
|
|
39
|
-
* .select(
|
|
40
|
-
* // If you use `sql` in a select statement, remember to call the `as`
|
|
41
|
-
* // method to give it an alias. Otherwise Kysely is not able to add
|
|
42
|
-
* // the column to the result type.
|
|
43
|
-
* sql<string>`concat(first_name, ' ', last_name)`.as('full_name')
|
|
44
|
-
* )
|
|
45
|
-
* .where(sql`birthdate between ${date1} and ${date2}`)
|
|
46
|
-
* // Here we assume we have list of nicknames for the person
|
|
47
|
-
* // (a list of strings) and we use the PostgreSQL `@>` operator
|
|
48
|
-
* // to test if all of them are valid nicknames for the user.
|
|
49
|
-
* .where('nicknames', '@>', sql`ARRAY[${sql.join(nicknames)}]`)
|
|
50
|
-
* .orderBy(sql`concat(first_name, ' ', last_name)`)
|
|
51
|
-
* .execute()
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* The generated SQL (PostgreSQL):
|
|
55
|
-
*
|
|
56
|
-
* ```sql
|
|
57
|
-
* select concat(first_name, ' ', last_name) as "full_name"
|
|
58
|
-
* from "person"
|
|
59
|
-
* where birthdate between $1 and $2
|
|
60
|
-
* and "nicknames" @> ARRAY[$3, $4, $5, $6, $7, $8, $9, $10]
|
|
61
|
-
* order by concat(first_name, ' ', last_name)
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* SQL snippets can be executed by calling the `execute` method and passing a `Kysely`
|
|
65
|
-
* instance as the only argument:
|
|
66
|
-
*
|
|
67
|
-
* ```ts
|
|
68
|
-
* const result = await sql<Person[]>`select * from person`.execute(db)
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* You can merge other `sql` expressions and queries using substitutions:
|
|
72
|
-
*
|
|
73
|
-
* ```ts
|
|
74
|
-
* const petName = db.selectFrom('pet').select('name').limit(1)
|
|
75
|
-
* const fullName = sql`concat(first_name, ' ', last_name)`
|
|
76
|
-
*
|
|
77
|
-
* sql`
|
|
78
|
-
* select ${fullName} as full_name, ${petName} as pet_name
|
|
79
|
-
* from person
|
|
80
|
-
* `
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* Substitutions also handle {@link ExpressionBuilder.ref},
|
|
84
|
-
* {@link DynamicModule.ref} and pretty much anything else you
|
|
85
|
-
* throw at it. Here's an example of calling a function in a
|
|
86
|
-
* type-safe way:
|
|
87
|
-
*
|
|
88
|
-
* ```ts
|
|
89
|
-
* db.selectFrom('person')
|
|
90
|
-
* .select([
|
|
91
|
-
* 'first_name',
|
|
92
|
-
* 'last_name',
|
|
93
|
-
* (eb) => {
|
|
94
|
-
* // The `eb.ref` method is type-safe and only accepts
|
|
95
|
-
* // column references that are possible.
|
|
96
|
-
* const firstName = eb.ref('first_name')
|
|
97
|
-
* const lastName = eb.ref('last_name')
|
|
98
|
-
*
|
|
99
|
-
* const fullName = sql<string>`concat(${firstName}, ' ', ${lastName})`
|
|
100
|
-
* return fullName.as('full_name')
|
|
101
|
-
* }
|
|
102
|
-
* ])
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* don't know if that amount of ceremony is worth the small increase in
|
|
106
|
-
* type-safety though... But it's possible.
|
|
107
|
-
*/
|
|
108
12
|
exports.sql = Object.assign((sqlFragments, ...parameters) => {
|
|
109
13
|
return new raw_builder_js_1.RawBuilder({
|
|
110
14
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
@@ -92,7 +92,7 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
|
|
|
92
92
|
* Makes the column the primary key.
|
|
93
93
|
*
|
|
94
94
|
* If you want to specify a composite primary key use the
|
|
95
|
-
* {@link
|
|
95
|
+
* {@link CreateTableBuilder.addPrimaryKeyConstraint} method.
|
|
96
96
|
*/
|
|
97
97
|
primaryKey(): AlterTableAddColumnBuilder;
|
|
98
98
|
/**
|
|
@@ -100,7 +100,7 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
|
|
|
100
100
|
*
|
|
101
101
|
* If your database engine doesn't support foreign key constraints in the
|
|
102
102
|
* column definition (like MySQL 5) you need to call the table level
|
|
103
|
-
* {@link
|
|
103
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
104
104
|
*
|
|
105
105
|
* ### Examples
|
|
106
106
|
*
|
|
@@ -114,7 +114,7 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
|
|
|
114
114
|
*
|
|
115
115
|
* If your database engine doesn't support foreign key constraints in the
|
|
116
116
|
* column definition (like MySQL 5) you need to call the table level
|
|
117
|
-
* {@link
|
|
117
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
118
118
|
*
|
|
119
119
|
* ### Examples
|
|
120
120
|
*
|
|
@@ -258,7 +258,7 @@ export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBu
|
|
|
258
258
|
* Makes the column the primary key.
|
|
259
259
|
*
|
|
260
260
|
* If you want to specify a composite primary key use the
|
|
261
|
-
* {@link
|
|
261
|
+
* {@link CreateTableBuilder.addPrimaryKeyConstraint} method.
|
|
262
262
|
*/
|
|
263
263
|
primaryKey(): AlterTableModifyColumnBuilder;
|
|
264
264
|
/**
|
|
@@ -266,7 +266,7 @@ export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBu
|
|
|
266
266
|
*
|
|
267
267
|
* If your database engine doesn't support foreign key constraints in the
|
|
268
268
|
* column definition (like MySQL 5) you need to call the table level
|
|
269
|
-
* {@link
|
|
269
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
270
270
|
*
|
|
271
271
|
* ### Examples
|
|
272
272
|
*
|
|
@@ -280,7 +280,7 @@ export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBu
|
|
|
280
280
|
*
|
|
281
281
|
* If your database engine doesn't support foreign key constraints in the
|
|
282
282
|
* column definition (like MySQL 5) you need to call the table level
|
|
283
|
-
* {@link
|
|
283
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
284
284
|
*
|
|
285
285
|
* ### Examples
|
|
286
286
|
*
|
|
@@ -16,7 +16,7 @@ export interface ColumnDefinitionBuilderInterface {
|
|
|
16
16
|
* Makes the column the primary key.
|
|
17
17
|
*
|
|
18
18
|
* If you want to specify a composite primary key use the
|
|
19
|
-
* {@link
|
|
19
|
+
* {@link CreateTableBuilder.addPrimaryKeyConstraint} method.
|
|
20
20
|
*/
|
|
21
21
|
primaryKey(): ColumnDefinitionBuilderInterface;
|
|
22
22
|
/**
|
|
@@ -24,7 +24,7 @@ export interface ColumnDefinitionBuilderInterface {
|
|
|
24
24
|
*
|
|
25
25
|
* If your database engine doesn't support foreign key constraints in the
|
|
26
26
|
* column definition (like MySQL 5) you need to call the table level
|
|
27
|
-
* {@link
|
|
27
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
28
28
|
*
|
|
29
29
|
* ### Examples
|
|
30
30
|
*
|
|
@@ -38,7 +38,7 @@ export interface ColumnDefinitionBuilderInterface {
|
|
|
38
38
|
*
|
|
39
39
|
* If your database engine doesn't support foreign key constraints in the
|
|
40
40
|
* column definition (like MySQL 5) you need to call the table level
|
|
41
|
-
* {@link
|
|
41
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
42
42
|
*
|
|
43
43
|
* ### Examples
|
|
44
44
|
*
|
|
@@ -175,7 +175,7 @@ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderI
|
|
|
175
175
|
* Makes the column the primary key.
|
|
176
176
|
*
|
|
177
177
|
* If you want to specify a composite primary key use the
|
|
178
|
-
* {@link
|
|
178
|
+
* {@link CreateTableBuilder.addPrimaryKeyConstraint} method.
|
|
179
179
|
*/
|
|
180
180
|
primaryKey(): ColumnDefinitionBuilder;
|
|
181
181
|
/**
|
|
@@ -183,7 +183,7 @@ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderI
|
|
|
183
183
|
*
|
|
184
184
|
* If your database engine doesn't support foreign key constraints in the
|
|
185
185
|
* column definition (like MySQL 5) you need to call the table level
|
|
186
|
-
* {@link
|
|
186
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
187
187
|
*
|
|
188
188
|
* ### Examples
|
|
189
189
|
*
|
|
@@ -197,7 +197,7 @@ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderI
|
|
|
197
197
|
*
|
|
198
198
|
* If your database engine doesn't support foreign key constraints in the
|
|
199
199
|
* column definition (like MySQL 5) you need to call the table level
|
|
200
|
-
* {@link
|
|
200
|
+
* {@link CreateTableBuilder.addForeignKeyConstraint} method instead.
|
|
201
201
|
*
|
|
202
202
|
* ### Examples
|
|
203
203
|
*
|
|
@@ -149,6 +149,60 @@ export declare class CreateTableBuilder<TB extends string, C extends string = ne
|
|
|
149
149
|
* ```
|
|
150
150
|
*/
|
|
151
151
|
addForeignKeyConstraint(constraintName: string, columns: C[], targetTable: string, targetColumns: string[], build?: ForeignKeyConstraintBuilderCallback): CreateTableBuilder<TB, C>;
|
|
152
|
+
/**
|
|
153
|
+
* This can be used to add any additional SQL to the front of the query __after__ the `create` keyword.
|
|
154
|
+
*
|
|
155
|
+
* Also see {@link temporary}.
|
|
156
|
+
*
|
|
157
|
+
* ### Examples
|
|
158
|
+
*
|
|
159
|
+
* ```ts
|
|
160
|
+
* db.schema.createTable('person')
|
|
161
|
+
* .modifyFront(sql`global temporary`)
|
|
162
|
+
* .addColumn('id', 'integer', col => col => primaryKey())
|
|
163
|
+
* .addColumn('first_name', 'varchar(64)', col => col.notNull())
|
|
164
|
+
* .addColumn('last_name', 'varchar(64), col => col.notNull())
|
|
165
|
+
* .execute()
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* The generated SQL (Postgres):
|
|
169
|
+
*
|
|
170
|
+
* ```sql
|
|
171
|
+
* create global temporary table "person" (
|
|
172
|
+
* "id" integer primary key,
|
|
173
|
+
* "first_name" varchar(64) not null,
|
|
174
|
+
* "last_name" varchar(64) not null
|
|
175
|
+
* )
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
modifyFront(modifier: AnyRawBuilder): CreateTableBuilder<TB, C>;
|
|
179
|
+
/**
|
|
180
|
+
* This can be used to add any additional SQL to the end of the query.
|
|
181
|
+
*
|
|
182
|
+
* Also see {@link onCommit}.
|
|
183
|
+
*
|
|
184
|
+
* ### Examples
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* db.schema.createTable('person')
|
|
188
|
+
* .addColumn('id', 'integer', col => col => primaryKey())
|
|
189
|
+
* .addColumn('first_name', 'varchar(64)', col => col.notNull())
|
|
190
|
+
* .addColumn('last_name', 'varchar(64), col => col.notNull())
|
|
191
|
+
* .modifyEnd(sql`collate utf8_unicode_ci`)
|
|
192
|
+
* .execute()
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* The generated SQL (MySQL):
|
|
196
|
+
*
|
|
197
|
+
* ```sql
|
|
198
|
+
* create table `person` (
|
|
199
|
+
* `id` integer primary key,
|
|
200
|
+
* `first_name` varchar(64) not null,
|
|
201
|
+
* `last_name` varchar(64) not null
|
|
202
|
+
* ) collate utf8_unicode_ci
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
modifyEnd(modifier: AnyRawBuilder): CreateTableBuilder<TB, C>;
|
|
152
206
|
toOperationNode(): CreateTableNode;
|
|
153
207
|
compile(): CompiledQuery;
|
|
154
208
|
execute(): Promise<void>;
|
|
@@ -206,6 +206,70 @@ class CreateTableBuilder {
|
|
|
206
206
|
createTableNode: create_table_node_js_1.CreateTableNode.cloneWithConstraint(this.#props.createTableNode, builder.toOperationNode()),
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* This can be used to add any additional SQL to the front of the query __after__ the `create` keyword.
|
|
211
|
+
*
|
|
212
|
+
* Also see {@link temporary}.
|
|
213
|
+
*
|
|
214
|
+
* ### Examples
|
|
215
|
+
*
|
|
216
|
+
* ```ts
|
|
217
|
+
* db.schema.createTable('person')
|
|
218
|
+
* .modifyFront(sql`global temporary`)
|
|
219
|
+
* .addColumn('id', 'integer', col => col => primaryKey())
|
|
220
|
+
* .addColumn('first_name', 'varchar(64)', col => col.notNull())
|
|
221
|
+
* .addColumn('last_name', 'varchar(64), col => col.notNull())
|
|
222
|
+
* .execute()
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* The generated SQL (Postgres):
|
|
226
|
+
*
|
|
227
|
+
* ```sql
|
|
228
|
+
* create global temporary table "person" (
|
|
229
|
+
* "id" integer primary key,
|
|
230
|
+
* "first_name" varchar(64) not null,
|
|
231
|
+
* "last_name" varchar(64) not null
|
|
232
|
+
* )
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
modifyFront(modifier) {
|
|
236
|
+
return new CreateTableBuilder({
|
|
237
|
+
...this.#props,
|
|
238
|
+
createTableNode: create_table_node_js_1.CreateTableNode.cloneWithFrontModifier(this.#props.createTableNode, modifier.toOperationNode()),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* This can be used to add any additional SQL to the end of the query.
|
|
243
|
+
*
|
|
244
|
+
* Also see {@link onCommit}.
|
|
245
|
+
*
|
|
246
|
+
* ### Examples
|
|
247
|
+
*
|
|
248
|
+
* ```ts
|
|
249
|
+
* db.schema.createTable('person')
|
|
250
|
+
* .addColumn('id', 'integer', col => col => primaryKey())
|
|
251
|
+
* .addColumn('first_name', 'varchar(64)', col => col.notNull())
|
|
252
|
+
* .addColumn('last_name', 'varchar(64), col => col.notNull())
|
|
253
|
+
* .modifyEnd(sql`collate utf8_unicode_ci`)
|
|
254
|
+
* .execute()
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* The generated SQL (MySQL):
|
|
258
|
+
*
|
|
259
|
+
* ```sql
|
|
260
|
+
* create table `person` (
|
|
261
|
+
* `id` integer primary key,
|
|
262
|
+
* `first_name` varchar(64) not null,
|
|
263
|
+
* `last_name` varchar(64) not null
|
|
264
|
+
* ) collate utf8_unicode_ci
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
modifyEnd(modifier) {
|
|
268
|
+
return new CreateTableBuilder({
|
|
269
|
+
...this.#props,
|
|
270
|
+
createTableNode: create_table_node_js_1.CreateTableNode.cloneWithEndModifier(this.#props.createTableNode, modifier.toOperationNode()),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
209
273
|
toOperationNode() {
|
|
210
274
|
return this.#props.executor.transformQuery(this.#props.createTableNode, this.#props.queryId);
|
|
211
275
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AnyRawBuilder } from './type-utils.js';
|
|
2
|
+
export declare type ExplainFormat = 'text' | 'xml' | 'json' | 'yaml' | 'traditional' | 'tree';
|
|
3
|
+
export interface Explainable {
|
|
4
|
+
explain<O extends Record<string, any> = Record<string, any>>(format?: ExplainFormat, options?: AnyRawBuilder): Promise<O[]>;
|
|
5
|
+
}
|