kysely 0.16.9 → 0.16.10

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Sami Koskimäki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -345,12 +345,12 @@ class ConnectionBuilder {
345
345
  async execute(callback) {
346
346
  const connection = await this.#props.driver.acquireConnection();
347
347
  const connectionProvider = new single_connection_provider_js_1.SingleConnectionProvider(connection);
348
- const transaction = new Kysely({
348
+ const db = new Kysely({
349
349
  ...this.#props,
350
350
  executor: this.#props.executor.withConnectionProvider(connectionProvider),
351
351
  });
352
352
  try {
353
- return await callback(transaction);
353
+ return await callback(db);
354
354
  }
355
355
  finally {
356
356
  await this.#props.driver.releaseConnection(connection);
@@ -564,8 +564,6 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
564
564
  * Return arbitrary expressions:
565
565
  *
566
566
  * ```ts
567
- * const { raw } = db
568
- *
569
567
  * const { id, full_name, first_pet_id } = await db
570
568
  * .insertInto('person')
571
569
  * .values({
@@ -574,7 +572,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
574
572
  * })
575
573
  * .returning([
576
574
  * 'id as id',
577
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
575
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
578
576
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
579
577
  * ])
580
578
  * .executeTakeFirst()
@@ -423,8 +423,6 @@ export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements R
423
423
  * Return arbitrary expressions:
424
424
  *
425
425
  * ```ts
426
- * const { raw } = db
427
- *
428
426
  * const { id, full_name, first_pet_id } = await db
429
427
  * .insertInto('person')
430
428
  * .values({
@@ -433,7 +431,7 @@ export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements R
433
431
  * })
434
432
  * .returning([
435
433
  * 'id as id',
436
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
434
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
437
435
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
438
436
  * ])
439
437
  * .executeTakeFirst()
@@ -45,8 +45,6 @@ export interface ReturningInterface<DB, TB extends keyof DB, O> {
45
45
  * Return arbitrary expressions:
46
46
  *
47
47
  * ```ts
48
- * const { raw } = db
49
- *
50
48
  * const { id, full_name, first_pet_id } = await db
51
49
  * .insertInto('person')
52
50
  * .values({
@@ -55,7 +53,7 @@ export interface ReturningInterface<DB, TB extends keyof DB, O> {
55
53
  * })
56
54
  * .returning([
57
55
  * 'id as id',
58
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
56
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
59
57
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
60
58
  * ])
61
59
  * .executeTakeFirst()
@@ -456,7 +456,10 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
456
456
  * same as calling `select(['id', 'first_name']).
457
457
  *
458
458
  * To select all columns of the query or specific tables see the
459
- * {@link SelectQueryBuilder.selectAll | selectAll} method.
459
+ * {@link selectAll} method.
460
+ *
461
+ * See the {@link if} method if you are looking for a way to add selections
462
+ * based on a runtime condition.
460
463
  *
461
464
  * ### Examples
462
465
  *
@@ -971,14 +974,12 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
971
974
  * `groupBy` also accepts an array:
972
975
  *
973
976
  * ```ts
974
- * const { raw } = db
975
- *
976
977
  * await db
977
978
  * .selectFrom('person')
978
979
  * .select([
979
980
  * 'first_name',
980
981
  * 'last_name',
981
- * raw('max(id)').as('max_id')
982
+ * db.raw('max(id)').as('max_id')
982
983
  * ])
983
984
  * .groupBy([
984
985
  * 'first_name',
@@ -999,17 +1000,15 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
999
1000
  * raw expressions:
1000
1001
  *
1001
1002
  * ```ts
1002
- * const { raw } = db
1003
- *
1004
1003
  * await db
1005
1004
  * .selectFrom('person')
1006
1005
  * .select([
1007
1006
  * 'first_name',
1008
1007
  * 'last_name',
1009
- * raw('max(id)').as('max_id')
1008
+ * db.raw('max(id)').as('max_id')
1010
1009
  * ])
1011
1010
  * .groupBy([
1012
- * raw('concat(first_name, last_name)'),
1011
+ * db.raw('concat(first_name, last_name)'),
1013
1012
  * (qb) => qb.selectFrom('pet').select('id').limit(1)
1014
1013
  * ])
1015
1014
  * .execute()
@@ -651,8 +651,6 @@ export declare class UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
651
651
  * Return arbitrary expressions:
652
652
  *
653
653
  * ```ts
654
- * const { raw } = db
655
- *
656
654
  * const { id, full_name, first_pet_id } = await db
657
655
  * .insertInto('person')
658
656
  * .values({
@@ -661,7 +659,7 @@ export declare class UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
661
659
  * })
662
660
  * .returning([
663
661
  * 'id as id',
664
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
662
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
665
663
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
666
664
  * ])
667
665
  * .executeTakeFirst()
@@ -29,9 +29,9 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
29
29
  }
30
30
  visitSelectQuery(node) {
31
31
  const wrapInParens = this.parentNode !== undefined &&
32
+ !insert_query_node_js_1.InsertQueryNode.is(this.parentNode) &&
32
33
  !create_view_node_js_1.CreateViewNode.is(this.parentNode) &&
33
- !union_node_js_1.UnionNode.is(this.parentNode) &&
34
- !insert_query_node_js_1.InsertQueryNode.is(this.parentNode);
34
+ !union_node_js_1.UnionNode.is(this.parentNode);
35
35
  if (wrapInParens) {
36
36
  this.append('(');
37
37
  }
@@ -285,12 +285,13 @@ class DefaultQueryCompiler extends operation_node_visitor_js_1.OperationNodeVisi
285
285
  this.visitNode(node.on);
286
286
  }
287
287
  visitRaw(node) {
288
- node.sqlFragments.forEach((sql, i) => {
289
- this.append(sql);
290
- if (node.params.length > i) {
291
- this.visitNode(node.params[i]);
288
+ const { sqlFragments, params } = node;
289
+ for (let i = 0; i < sqlFragments.length; ++i) {
290
+ this.append(sqlFragments[i]);
291
+ if (params.length > i) {
292
+ this.visitNode(params[i]);
292
293
  }
293
- });
294
+ }
294
295
  }
295
296
  visitOperator(node) {
296
297
  this.append(node.operator);
@@ -9,7 +9,6 @@ const data_type_node_js_1 = require("../operation-node/data-type-node.js");
9
9
  const drop_column_node_js_1 = require("../operation-node/drop-column-node.js");
10
10
  const identifier_node_js_1 = require("../operation-node/identifier-node.js");
11
11
  const rename_column_node_js_1 = require("../operation-node/rename-column-node.js");
12
- const table_node_js_1 = require("../operation-node/table-node.js");
13
12
  const object_utils_js_1 = require("../util/object-utils.js");
14
13
  const prevent_await_js_1 = require("../util/prevent-await.js");
15
14
  const column_definition_builder_js_1 = require("./column-definition-builder.js");
@@ -22,6 +21,7 @@ const check_constraint_node_js_1 = require("../operation-node/check-constraint-n
22
21
  const foreign_key_constraint_node_js_1 = require("../operation-node/foreign-key-constraint-node.js");
23
22
  const column_node_js_1 = require("../operation-node/column-node.js");
24
23
  const default_value_parser_js_1 = require("../parser/default-value-parser.js");
24
+ const table_parser_js_1 = require("../parser/table-parser.js");
25
25
  /**
26
26
  * This builder can be used to create a `alter table` query.
27
27
  */
@@ -34,7 +34,7 @@ class AlterTableBuilder {
34
34
  return new AlterTableExecutor({
35
35
  ...this.#props,
36
36
  alterTableNode: alter_table_node_js_1.AlterTableNode.cloneWith(this.#props.alterTableNode, {
37
- renameTo: table_node_js_1.TableNode.create(newTableName),
37
+ renameTo: (0, table_parser_js_1.parseTable)(newTableName),
38
38
  }),
39
39
  });
40
40
  }
@@ -104,7 +104,7 @@ class AlterTableBuilder {
104
104
  addForeignKeyConstraint(constraintName, columns, targetTable, targetColumns) {
105
105
  return new AlterTableAddForeignKeyConstraintBuilder({
106
106
  ...this.#props,
107
- constraintBuilder: new foreign_key_constraint_builder_js_1.ForeignKeyConstraintBuilder(foreign_key_constraint_node_js_1.ForeignKeyConstraintNode.create(columns.map(column_node_js_1.ColumnNode.create), table_node_js_1.TableNode.create(targetTable), targetColumns.map(column_node_js_1.ColumnNode.create), constraintName)),
107
+ constraintBuilder: new foreign_key_constraint_builder_js_1.ForeignKeyConstraintBuilder(foreign_key_constraint_node_js_1.ForeignKeyConstraintNode.create(columns.map(column_node_js_1.ColumnNode.create), (0, table_parser_js_1.parseTable)(targetTable), targetColumns.map(column_node_js_1.ColumnNode.create), constraintName)),
108
108
  });
109
109
  }
110
110
  }
@@ -8,12 +8,12 @@ const column_definition_builder_js_1 = require("./column-definition-builder.js")
8
8
  const object_utils_js_1 = require("../util/object-utils.js");
9
9
  const foreign_key_constraint_node_js_1 = require("../operation-node/foreign-key-constraint-node.js");
10
10
  const column_node_js_1 = require("../operation-node/column-node.js");
11
- const table_node_js_1 = require("../operation-node/table-node.js");
12
11
  const foreign_key_constraint_builder_js_1 = require("./foreign-key-constraint-builder.js");
13
12
  const data_type_parser_js_1 = require("../parser/data-type-parser.js");
14
13
  const primary_constraint_node_js_1 = require("../operation-node/primary-constraint-node.js");
15
14
  const unique_constraint_node_js_1 = require("../operation-node/unique-constraint-node.js");
16
15
  const check_constraint_node_js_1 = require("../operation-node/check-constraint-node.js");
16
+ const table_parser_js_1 = require("../parser/table-parser.js");
17
17
  /**
18
18
  * This builder can be used to create a `create table` query.
19
19
  */
@@ -195,7 +195,7 @@ class CreateTableBuilder {
195
195
  * ```
196
196
  */
197
197
  addForeignKeyConstraint(constraintName, columns, targetTable, targetColumns, build = object_utils_js_1.noop) {
198
- const builder = build(new foreign_key_constraint_builder_js_1.ForeignKeyConstraintBuilder(foreign_key_constraint_node_js_1.ForeignKeyConstraintNode.create(columns.map(column_node_js_1.ColumnNode.create), table_node_js_1.TableNode.create(targetTable), targetColumns.map(column_node_js_1.ColumnNode.create), constraintName)));
198
+ const builder = build(new foreign_key_constraint_builder_js_1.ForeignKeyConstraintBuilder(foreign_key_constraint_node_js_1.ForeignKeyConstraintNode.create(columns.map(column_node_js_1.ColumnNode.create), (0, table_parser_js_1.parseTable)(targetTable), targetColumns.map(column_node_js_1.ColumnNode.create), constraintName)));
199
199
  return new CreateTableBuilder({
200
200
  ...this.#props,
201
201
  createTableNode: create_table_node_js_1.CreateTableNode.cloneWithConstraint(this.#props.createTableNode, builder.toOperationNode()),
@@ -340,12 +340,12 @@ export class ConnectionBuilder {
340
340
  async execute(callback) {
341
341
  const connection = await this.#props.driver.acquireConnection();
342
342
  const connectionProvider = new SingleConnectionProvider(connection);
343
- const transaction = new Kysely({
343
+ const db = new Kysely({
344
344
  ...this.#props,
345
345
  executor: this.#props.executor.withConnectionProvider(connectionProvider),
346
346
  });
347
347
  try {
348
- return await callback(transaction);
348
+ return await callback(db);
349
349
  }
350
350
  finally {
351
351
  await this.#props.driver.releaseConnection(connection);
@@ -564,8 +564,6 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
564
564
  * Return arbitrary expressions:
565
565
  *
566
566
  * ```ts
567
- * const { raw } = db
568
- *
569
567
  * const { id, full_name, first_pet_id } = await db
570
568
  * .insertInto('person')
571
569
  * .values({
@@ -574,7 +572,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
574
572
  * })
575
573
  * .returning([
576
574
  * 'id as id',
577
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
575
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
578
576
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
579
577
  * ])
580
578
  * .executeTakeFirst()
@@ -423,8 +423,6 @@ export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements R
423
423
  * Return arbitrary expressions:
424
424
  *
425
425
  * ```ts
426
- * const { raw } = db
427
- *
428
426
  * const { id, full_name, first_pet_id } = await db
429
427
  * .insertInto('person')
430
428
  * .values({
@@ -433,7 +431,7 @@ export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements R
433
431
  * })
434
432
  * .returning([
435
433
  * 'id as id',
436
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
434
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
437
435
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
438
436
  * ])
439
437
  * .executeTakeFirst()
@@ -45,8 +45,6 @@ export interface ReturningInterface<DB, TB extends keyof DB, O> {
45
45
  * Return arbitrary expressions:
46
46
  *
47
47
  * ```ts
48
- * const { raw } = db
49
- *
50
48
  * const { id, full_name, first_pet_id } = await db
51
49
  * .insertInto('person')
52
50
  * .values({
@@ -55,7 +53,7 @@ export interface ReturningInterface<DB, TB extends keyof DB, O> {
55
53
  * })
56
54
  * .returning([
57
55
  * 'id as id',
58
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
56
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
59
57
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
60
58
  * ])
61
59
  * .executeTakeFirst()
@@ -456,7 +456,10 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
456
456
  * same as calling `select(['id', 'first_name']).
457
457
  *
458
458
  * To select all columns of the query or specific tables see the
459
- * {@link SelectQueryBuilder.selectAll | selectAll} method.
459
+ * {@link selectAll} method.
460
+ *
461
+ * See the {@link if} method if you are looking for a way to add selections
462
+ * based on a runtime condition.
460
463
  *
461
464
  * ### Examples
462
465
  *
@@ -971,14 +974,12 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
971
974
  * `groupBy` also accepts an array:
972
975
  *
973
976
  * ```ts
974
- * const { raw } = db
975
- *
976
977
  * await db
977
978
  * .selectFrom('person')
978
979
  * .select([
979
980
  * 'first_name',
980
981
  * 'last_name',
981
- * raw('max(id)').as('max_id')
982
+ * db.raw('max(id)').as('max_id')
982
983
  * ])
983
984
  * .groupBy([
984
985
  * 'first_name',
@@ -999,17 +1000,15 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
999
1000
  * raw expressions:
1000
1001
  *
1001
1002
  * ```ts
1002
- * const { raw } = db
1003
- *
1004
1003
  * await db
1005
1004
  * .selectFrom('person')
1006
1005
  * .select([
1007
1006
  * 'first_name',
1008
1007
  * 'last_name',
1009
- * raw('max(id)').as('max_id')
1008
+ * db.raw('max(id)').as('max_id')
1010
1009
  * ])
1011
1010
  * .groupBy([
1012
- * raw('concat(first_name, last_name)'),
1011
+ * db.raw('concat(first_name, last_name)'),
1013
1012
  * (qb) => qb.selectFrom('pet').select('id').limit(1)
1014
1013
  * ])
1015
1014
  * .execute()
@@ -651,8 +651,6 @@ export declare class UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
651
651
  * Return arbitrary expressions:
652
652
  *
653
653
  * ```ts
654
- * const { raw } = db
655
- *
656
654
  * const { id, full_name, first_pet_id } = await db
657
655
  * .insertInto('person')
658
656
  * .values({
@@ -661,7 +659,7 @@ export declare class UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
661
659
  * })
662
660
  * .returning([
663
661
  * 'id as id',
664
- * raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
662
+ * db.raw<string>(`concat(first_name, ' ', last_name)`).as('full_name'),
665
663
  * (qb) => qb.selectFrom('pets').select('pet.id').limit(1).as('first_pet_id')
666
664
  * ])
667
665
  * .executeTakeFirst()
@@ -27,9 +27,9 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
27
27
  }
28
28
  visitSelectQuery(node) {
29
29
  const wrapInParens = this.parentNode !== undefined &&
30
+ !InsertQueryNode.is(this.parentNode) &&
30
31
  !CreateViewNode.is(this.parentNode) &&
31
- !UnionNode.is(this.parentNode) &&
32
- !InsertQueryNode.is(this.parentNode);
32
+ !UnionNode.is(this.parentNode);
33
33
  if (wrapInParens) {
34
34
  this.append('(');
35
35
  }
@@ -283,12 +283,13 @@ export class DefaultQueryCompiler extends OperationNodeVisitor {
283
283
  this.visitNode(node.on);
284
284
  }
285
285
  visitRaw(node) {
286
- node.sqlFragments.forEach((sql, i) => {
287
- this.append(sql);
288
- if (node.params.length > i) {
289
- this.visitNode(node.params[i]);
286
+ const { sqlFragments, params } = node;
287
+ for (let i = 0; i < sqlFragments.length; ++i) {
288
+ this.append(sqlFragments[i]);
289
+ if (params.length > i) {
290
+ this.visitNode(params[i]);
290
291
  }
291
- });
292
+ }
292
293
  }
293
294
  visitOperator(node) {
294
295
  this.append(node.operator);
@@ -7,7 +7,6 @@ import { DataTypeNode, } from '../operation-node/data-type-node.js';
7
7
  import { DropColumnNode } from '../operation-node/drop-column-node.js';
8
8
  import { IdentifierNode } from '../operation-node/identifier-node.js';
9
9
  import { RenameColumnNode } from '../operation-node/rename-column-node.js';
10
- import { TableNode } from '../operation-node/table-node.js';
11
10
  import { freeze } from '../util/object-utils.js';
12
11
  import { preventAwait } from '../util/prevent-await.js';
13
12
  import { ColumnDefinitionBuilder, } from './column-definition-builder.js';
@@ -20,6 +19,7 @@ import { CheckConstraintNode } from '../operation-node/check-constraint-node.js'
20
19
  import { ForeignKeyConstraintNode } from '../operation-node/foreign-key-constraint-node.js';
21
20
  import { ColumnNode } from '../operation-node/column-node.js';
22
21
  import { parseDefaultValueExpression, } from '../parser/default-value-parser.js';
22
+ import { parseTable } from '../parser/table-parser.js';
23
23
  /**
24
24
  * This builder can be used to create a `alter table` query.
25
25
  */
@@ -32,7 +32,7 @@ export class AlterTableBuilder {
32
32
  return new AlterTableExecutor({
33
33
  ...this.#props,
34
34
  alterTableNode: AlterTableNode.cloneWith(this.#props.alterTableNode, {
35
- renameTo: TableNode.create(newTableName),
35
+ renameTo: parseTable(newTableName),
36
36
  }),
37
37
  });
38
38
  }
@@ -102,7 +102,7 @@ export class AlterTableBuilder {
102
102
  addForeignKeyConstraint(constraintName, columns, targetTable, targetColumns) {
103
103
  return new AlterTableAddForeignKeyConstraintBuilder({
104
104
  ...this.#props,
105
- constraintBuilder: new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(columns.map(ColumnNode.create), TableNode.create(targetTable), targetColumns.map(ColumnNode.create), constraintName)),
105
+ constraintBuilder: new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(columns.map(ColumnNode.create), parseTable(targetTable), targetColumns.map(ColumnNode.create), constraintName)),
106
106
  });
107
107
  }
108
108
  }
@@ -6,12 +6,12 @@ import { ColumnDefinitionBuilder } from './column-definition-builder.js';
6
6
  import { freeze, noop } from '../util/object-utils.js';
7
7
  import { ForeignKeyConstraintNode } from '../operation-node/foreign-key-constraint-node.js';
8
8
  import { ColumnNode } from '../operation-node/column-node.js';
9
- import { TableNode } from '../operation-node/table-node.js';
10
9
  import { ForeignKeyConstraintBuilder } from './foreign-key-constraint-builder.js';
11
10
  import { parseDataTypeExpression, } from '../parser/data-type-parser.js';
12
11
  import { PrimaryConstraintNode } from '../operation-node/primary-constraint-node.js';
13
12
  import { UniqueConstraintNode } from '../operation-node/unique-constraint-node.js';
14
13
  import { CheckConstraintNode } from '../operation-node/check-constraint-node.js';
14
+ import { parseTable } from '../parser/table-parser.js';
15
15
  /**
16
16
  * This builder can be used to create a `create table` query.
17
17
  */
@@ -193,7 +193,7 @@ export class CreateTableBuilder {
193
193
  * ```
194
194
  */
195
195
  addForeignKeyConstraint(constraintName, columns, targetTable, targetColumns, build = noop) {
196
- const builder = build(new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(columns.map(ColumnNode.create), TableNode.create(targetTable), targetColumns.map(ColumnNode.create), constraintName)));
196
+ const builder = build(new ForeignKeyConstraintBuilder(ForeignKeyConstraintNode.create(columns.map(ColumnNode.create), parseTable(targetTable), targetColumns.map(ColumnNode.create), constraintName)));
197
197
  return new CreateTableBuilder({
198
198
  ...this.#props,
199
199
  createTableNode: CreateTableNode.cloneWithConstraint(this.#props.createTableNode, builder.toOperationNode()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kysely",
3
- "version": "0.16.9",
3
+ "version": "0.16.10",
4
4
  "description": "Type safe SQL query builder",
5
5
  "repository": {
6
6
  "type": "git",