kysely 0.17.1 → 0.17.2

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.
Files changed (67) hide show
  1. package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +19 -0
  2. package/dist/cjs/driver/default-connection-provider.d.ts +1 -1
  3. package/dist/cjs/driver/default-connection-provider.js +2 -2
  4. package/dist/cjs/driver/dummy-driver.d.ts +8 -0
  5. package/dist/cjs/driver/dummy-driver.js +8 -0
  6. package/dist/cjs/driver/single-connection-provider.d.ts +1 -1
  7. package/dist/cjs/driver/single-connection-provider.js +2 -2
  8. package/dist/cjs/parser/complex-expression-parser.d.ts +1 -1
  9. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-transformer.d.ts +2 -1
  10. package/dist/cjs/query-builder/delete-query-builder.d.ts +12 -5
  11. package/dist/cjs/query-builder/expression-builder.d.ts +1 -1
  12. package/dist/cjs/query-builder/expression-builder.js +2 -2
  13. package/dist/cjs/query-builder/function-builder.js +2 -2
  14. package/dist/cjs/query-builder/on-conflict-builder.d.ts +24 -10
  15. package/dist/cjs/query-builder/select-query-builder.d.ts +12 -5
  16. package/dist/cjs/query-builder/update-query-builder.d.ts +12 -5
  17. package/dist/cjs/query-builder/where-interface.d.ts +12 -5
  18. package/dist/cjs/query-executor/default-query-executor.d.ts +8 -5
  19. package/dist/cjs/query-executor/default-query-executor.js +2 -2
  20. package/dist/cjs/query-executor/noop-query-executor.d.ts +7 -4
  21. package/dist/cjs/query-executor/noop-query-executor.js +2 -2
  22. package/dist/cjs/query-executor/query-executor-base.d.ts +62 -0
  23. package/dist/cjs/query-executor/query-executor-base.js +46 -0
  24. package/dist/cjs/query-executor/query-executor.d.ts +16 -17
  25. package/dist/cjs/query-executor/query-executor.js +0 -59
  26. package/dist/cjs/raw-builder/sql.d.ts +11 -3
  27. package/dist/cjs/raw-builder/sql.js +10 -2
  28. package/dist/cjs/schema/alter-table-builder.d.ts +24 -2
  29. package/dist/cjs/schema/alter-table-builder.js +20 -0
  30. package/dist/cjs/schema/column-definition-builder.d.ts +4 -2
  31. package/dist/cjs/schema/create-table-builder.d.ts +1 -1
  32. package/dist/cjs/schema/create-table-builder.js +1 -1
  33. package/dist/cjs/util/type-utils.d.ts +1 -1
  34. package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +19 -0
  35. package/dist/esm/driver/default-connection-provider.d.ts +1 -1
  36. package/dist/esm/driver/default-connection-provider.js +2 -2
  37. package/dist/esm/driver/dummy-driver.d.ts +8 -0
  38. package/dist/esm/driver/dummy-driver.js +8 -0
  39. package/dist/esm/driver/single-connection-provider.d.ts +1 -1
  40. package/dist/esm/driver/single-connection-provider.js +2 -2
  41. package/dist/esm/parser/complex-expression-parser.d.ts +1 -1
  42. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-transformer.d.ts +2 -1
  43. package/dist/esm/query-builder/delete-query-builder.d.ts +12 -5
  44. package/dist/esm/query-builder/expression-builder.d.ts +1 -1
  45. package/dist/esm/query-builder/expression-builder.js +1 -1
  46. package/dist/esm/query-builder/function-builder.js +1 -1
  47. package/dist/esm/query-builder/on-conflict-builder.d.ts +24 -10
  48. package/dist/esm/query-builder/select-query-builder.d.ts +12 -5
  49. package/dist/esm/query-builder/update-query-builder.d.ts +12 -5
  50. package/dist/esm/query-builder/where-interface.d.ts +12 -5
  51. package/dist/esm/query-executor/default-query-executor.d.ts +8 -5
  52. package/dist/esm/query-executor/default-query-executor.js +2 -2
  53. package/dist/esm/query-executor/noop-query-executor.d.ts +7 -4
  54. package/dist/esm/query-executor/noop-query-executor.js +2 -2
  55. package/dist/esm/query-executor/query-executor-base.d.ts +62 -0
  56. package/dist/esm/query-executor/query-executor-base.js +43 -0
  57. package/dist/esm/query-executor/query-executor.d.ts +16 -17
  58. package/dist/esm/query-executor/query-executor.js +1 -57
  59. package/dist/esm/raw-builder/sql.d.ts +11 -3
  60. package/dist/esm/raw-builder/sql.js +10 -2
  61. package/dist/esm/schema/alter-table-builder.d.ts +24 -2
  62. package/dist/esm/schema/alter-table-builder.js +20 -0
  63. package/dist/esm/schema/column-definition-builder.d.ts +4 -2
  64. package/dist/esm/schema/create-table-builder.d.ts +1 -1
  65. package/dist/esm/schema/create-table-builder.js +1 -1
  66. package/dist/esm/util/type-utils.d.ts +1 -1
  67. package/package.json +9 -9
@@ -1,20 +1,24 @@
1
1
  import { ConnectionProvider } from '../driver/connection-provider.js';
2
- import { DatabaseConnection, QueryResult } from '../driver/database-connection.js';
2
+ import { QueryResult } from '../driver/database-connection.js';
3
3
  import { CompiledQuery } from '../query-compiler/compiled-query.js';
4
4
  import { RootOperationNode } from '../query-compiler/query-compiler.js';
5
5
  import { KyselyPlugin } from '../plugin/kysely-plugin.js';
6
6
  import { QueryId } from '../util/query-id.js';
7
7
  import { DialectAdapter } from '../dialect/dialect-adapter.js';
8
8
  /**
9
- * This class abstracts away the details of how to compile a query into SQL
9
+ * This interface abstracts away the details of how to compile a query into SQL
10
10
  * and execute it. Instead of passing around all those details, {@link SelectQueryBuilder}
11
11
  * and other classes that execute queries can just pass around and instance of
12
12
  * `QueryExecutor`.
13
13
  */
14
- export declare abstract class QueryExecutor implements ConnectionProvider {
15
- #private;
16
- constructor(plugins?: KyselyPlugin[]);
17
- abstract get adapter(): DialectAdapter;
14
+ export interface QueryExecutor extends ConnectionProvider {
15
+ /**
16
+ * Returns the adapter for the current dialect.
17
+ */
18
+ get adapter(): DialectAdapter;
19
+ /**
20
+ * Returns all installed plugins.
21
+ */
18
22
  get plugins(): ReadonlyArray<KyselyPlugin>;
19
23
  /**
20
24
  * Given the query the user has built (expressed as an operation node tree)
@@ -27,12 +31,7 @@ export declare abstract class QueryExecutor implements ConnectionProvider {
27
31
  * the output of {@link transformQuery} into this method but you can
28
32
  * compile any query using this method.
29
33
  */
30
- abstract compileQuery(node: RootOperationNode, queryId: QueryId): CompiledQuery;
31
- /**
32
- * Provides a connection for the callback and takes care of disposing
33
- * the connection after the callback has been run.
34
- */
35
- abstract provideConnection<T>(consumer: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
34
+ compileQuery(node: RootOperationNode, queryId: QueryId): CompiledQuery;
36
35
  /**
37
36
  * Executes a compiled query and runs the result through all plugins'
38
37
  * `transformResult` method.
@@ -41,24 +40,24 @@ export declare abstract class QueryExecutor implements ConnectionProvider {
41
40
  /**
42
41
  * Returns a copy of this executor with a new connection provider.
43
42
  */
44
- abstract withConnectionProvider(connectionProvider: ConnectionProvider): QueryExecutor;
43
+ withConnectionProvider(connectionProvider: ConnectionProvider): QueryExecutor;
45
44
  /**
46
45
  * Returns a copy of this executor with a plugin added as the
47
46
  * last plugin.
48
47
  */
49
- abstract withPlugin(plugin: KyselyPlugin): QueryExecutor;
48
+ withPlugin(plugin: KyselyPlugin): QueryExecutor;
50
49
  /**
51
50
  * Returns a copy of this executor with a list of plugins added
52
51
  * as the last plugins.
53
52
  */
54
- abstract withPlugins(plugin: ReadonlyArray<KyselyPlugin>): QueryExecutor;
53
+ withPlugins(plugin: ReadonlyArray<KyselyPlugin>): QueryExecutor;
55
54
  /**
56
55
  * Returns a copy of this executor with a plugin added as the
57
56
  * first plugin.
58
57
  */
59
- abstract withPluginAtFront(plugin: KyselyPlugin): QueryExecutor;
58
+ withPluginAtFront(plugin: KyselyPlugin): QueryExecutor;
60
59
  /**
61
60
  * Returns a copy of this executor without any plugins.
62
61
  */
63
- abstract withoutPlugins(): QueryExecutor;
62
+ withoutPlugins(): QueryExecutor;
64
63
  }
@@ -1,61 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryExecutor = void 0;
4
- const object_utils_js_1 = require("../util/object-utils.js");
5
- const NO_PLUGINS = (0, object_utils_js_1.freeze)([]);
6
- /**
7
- * This class abstracts away the details of how to compile a query into SQL
8
- * and execute it. Instead of passing around all those details, {@link SelectQueryBuilder}
9
- * and other classes that execute queries can just pass around and instance of
10
- * `QueryExecutor`.
11
- */
12
- class QueryExecutor {
13
- #plugins;
14
- constructor(plugins) {
15
- this.#plugins = plugins ?? NO_PLUGINS;
16
- }
17
- get plugins() {
18
- return this.#plugins;
19
- }
20
- /**
21
- * Given the query the user has built (expressed as an operation node tree)
22
- * this method runs it through all plugins' `transformQuery` methods and
23
- * returns the result.
24
- */
25
- transformQuery(node, queryId) {
26
- for (const plugin of this.#plugins) {
27
- const transformedNode = plugin.transformQuery({ node, queryId });
28
- // We need to do a runtime check here. There is no good way
29
- // to write types that enforce this constraint.
30
- if (transformedNode.kind === node.kind) {
31
- node = transformedNode;
32
- }
33
- else {
34
- throw new Error([
35
- `KyselyPlugin.transformQuery must return a node`,
36
- `of the same kind that was given to it.`,
37
- `The plugin was given a ${node.kind}`,
38
- `but it returned a ${transformedNode.kind}`,
39
- ].join(' '));
40
- }
41
- }
42
- return node;
43
- }
44
- /**
45
- * Executes a compiled query and runs the result through all plugins'
46
- * `transformResult` method.
47
- */
48
- async executeQuery(compiledQuery, queryId) {
49
- return await this.provideConnection(async (connection) => {
50
- const result = await connection.executeQuery(compiledQuery);
51
- return this.#transformResult(result, queryId);
52
- });
53
- }
54
- async #transformResult(result, queryId) {
55
- for (const plugin of this.#plugins) {
56
- result = await plugin.transformResult({ result, queryId });
57
- }
58
- return result;
59
- }
60
- }
61
- exports.QueryExecutor = QueryExecutor;
@@ -221,7 +221,7 @@ export interface Sql {
221
221
  * sql.id('first_name')
222
222
  * ]
223
223
  *
224
- * sql`BEFORE ${sql.array(things, sql`::varchar, `)} AFTER`
224
+ * sql`BEFORE ${sql.join(things, sql`::varchar, `)} AFTER`
225
225
  * ```
226
226
  *
227
227
  * The generated SQL (PostgreSQL):
@@ -281,7 +281,7 @@ export interface Sql {
281
281
  * from "person"
282
282
  * where birthdate between $1 and $2
283
283
  * and "nicknames" @> ARRAY[$3, $4, $5, $6, $7, $8, $9, $10]
284
- * order by concate(first_name, ' ', last_name)
284
+ * order by concat(first_name, ' ', last_name)
285
285
  * ```
286
286
  *
287
287
  * SQL snippets can be executed by calling the `execute` method and passing a `Kysely`
@@ -313,7 +313,15 @@ export interface Sql {
313
313
  * .select([
314
314
  * 'first_name',
315
315
  * 'last_name',
316
- * (eb) => sql<string>`concat(${eb.ref('first_name')}, ' ', ${eb.ref('last_name')})`.as('full_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
+ * }
317
325
  * ])
318
326
  * ```
319
327
  *
@@ -58,7 +58,7 @@ const raw_builder_js_1 = require("./raw-builder.js");
58
58
  * from "person"
59
59
  * where birthdate between $1 and $2
60
60
  * and "nicknames" @> ARRAY[$3, $4, $5, $6, $7, $8, $9, $10]
61
- * order by concate(first_name, ' ', last_name)
61
+ * order by concat(first_name, ' ', last_name)
62
62
  * ```
63
63
  *
64
64
  * SQL snippets can be executed by calling the `execute` method and passing a `Kysely`
@@ -90,7 +90,15 @@ const raw_builder_js_1 = require("./raw-builder.js");
90
90
  * .select([
91
91
  * 'first_name',
92
92
  * 'last_name',
93
- * (eb) => sql<string>`concat(${eb.ref('first_name')}, ' ', ${eb.ref('last_name')})`.as('full_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
+ * }
94
102
  * ])
95
103
  * ```
96
104
  *
@@ -23,6 +23,13 @@ export declare class AlterTableBuilder {
23
23
  alterColumn(column: string): AlterColumnBuilder;
24
24
  dropColumn(column: string): AlterTableExecutor;
25
25
  renameColumn(column: string, newColumn: string): AlterTableExecutor;
26
+ /**
27
+ * See {@link CreateTableBuilder.addColumn}
28
+ *
29
+ * Unlike {@link CreateTableBuilder.addColumn} this method returns the column builder
30
+ * and doesn't take a callback as the last argument. This is because you can only
31
+ * add one column per `ALTER TABLE` query.
32
+ */
26
33
  addColumn(columnName: string, dataType: DataTypeExpression): AlterTableAddColumnBuilder;
27
34
  /**
28
35
  * Creates an `alter table modify column` query. The `modify column` statement
@@ -30,8 +37,21 @@ export declare class AlterTableBuilder {
30
37
  * should use the `alterColumn` method.
31
38
  */
32
39
  modifyColumn(columnName: string, dataType: DataTypeExpression): AlterTableModifyColumnBuilder;
40
+ /**
41
+ * See {@link CreateTableBuilder.addUniqueConstraint}
42
+ */
33
43
  addUniqueConstraint(constraintName: string, columns: string[]): AlterTableExecutor;
44
+ /**
45
+ * See {@link CreateTableBuilder.addCheckConstraint}
46
+ */
34
47
  addCheckConstraint(constraintName: string, checkExpression: AnyRawBuilder): AlterTableExecutor;
48
+ /**
49
+ * See {@link CreateTableBuilder.addForeignKeyConstraint}
50
+ *
51
+ * Unlike {@link CreateTableBuilder.addForeignKeyConstraint} this method returns
52
+ * the constraint builder and doesn't take a callback as the last argument. This
53
+ * is because you can only add one column per `ALTER TABLE` query.
54
+ */
35
55
  addForeignKeyConstraint(constraintName: string, columns: string[], targetTable: string, targetColumns: string[]): AlterTableAddForeignKeyConstraintBuilder;
36
56
  }
37
57
  export interface AlterTableBuilderProps {
@@ -142,7 +162,8 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
142
162
  * .execute()
143
163
  * ```
144
164
  *
145
- * Raw {@link sql} expressions are also supported:
165
+ * Values passed to `defaultTo` are interpreted as value literals by default. You can define
166
+ * an arbitrary SQL expression using the {@link sql} template tag:
146
167
  *
147
168
  * ```ts
148
169
  * import { sql } from 'kysely'
@@ -306,7 +327,8 @@ export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBu
306
327
  * .execute()
307
328
  * ```
308
329
  *
309
- * Raw {@link sql} expressions are also supported:
330
+ * Values passed to `defaultTo` are interpreted as value literals by default. You can define
331
+ * an arbitrary SQL expression using the {@link sql} template tag:
310
332
  *
311
333
  * ```ts
312
334
  * import { sql } from 'kysely'
@@ -68,6 +68,13 @@ class AlterTableBuilder {
68
68
  }),
69
69
  });
70
70
  }
71
+ /**
72
+ * See {@link CreateTableBuilder.addColumn}
73
+ *
74
+ * Unlike {@link CreateTableBuilder.addColumn} this method returns the column builder
75
+ * and doesn't take a callback as the last argument. This is because you can only
76
+ * add one column per `ALTER TABLE` query.
77
+ */
71
78
  addColumn(columnName, dataType) {
72
79
  return new AlterTableAddColumnBuilder({
73
80
  ...this.#props,
@@ -85,6 +92,9 @@ class AlterTableBuilder {
85
92
  columnBuilder: new column_definition_builder_js_1.ColumnDefinitionBuilder(column_definition_node_js_1.ColumnDefinitionNode.create(columnName, (0, data_type_parser_js_1.parseDataTypeExpression)(dataType))),
86
93
  });
87
94
  }
95
+ /**
96
+ * See {@link CreateTableBuilder.addUniqueConstraint}
97
+ */
88
98
  addUniqueConstraint(constraintName, columns) {
89
99
  return new AlterTableExecutor({
90
100
  ...this.#props,
@@ -93,6 +103,9 @@ class AlterTableBuilder {
93
103
  }),
94
104
  });
95
105
  }
106
+ /**
107
+ * See {@link CreateTableBuilder.addCheckConstraint}
108
+ */
96
109
  addCheckConstraint(constraintName, checkExpression) {
97
110
  return new AlterTableExecutor({
98
111
  ...this.#props,
@@ -101,6 +114,13 @@ class AlterTableBuilder {
101
114
  }),
102
115
  });
103
116
  }
117
+ /**
118
+ * See {@link CreateTableBuilder.addForeignKeyConstraint}
119
+ *
120
+ * Unlike {@link CreateTableBuilder.addForeignKeyConstraint} this method returns
121
+ * the constraint builder and doesn't take a callback as the last argument. This
122
+ * is because you can only add one column per `ALTER TABLE` query.
123
+ */
104
124
  addForeignKeyConstraint(constraintName, columns, targetTable, targetColumns) {
105
125
  return new AlterTableAddForeignKeyConstraintBuilder({
106
126
  ...this.#props,
@@ -83,7 +83,8 @@ export interface ColumnDefinitionBuilderInterface {
83
83
  * .execute()
84
84
  * ```
85
85
  *
86
- * Raw {@link sql} expressions are also supported:
86
+ * Values passed to `defaultTo` are interpreted as value literals by default. You can define
87
+ * an arbitrary SQL expression using the {@link sql} template tag:
87
88
  *
88
89
  * ```ts
89
90
  * import { sql } from 'kysely'
@@ -241,7 +242,8 @@ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderI
241
242
  * .execute()
242
243
  * ```
243
244
  *
244
- * Raw {@link sql} expressions are also supported:
245
+ * Values passed to `defaultTo` are interpreted as value literals by default. You can define
246
+ * an arbitrary SQL expression using the {@link sql} template tag:
245
247
  *
246
248
  * ```ts
247
249
  * import { sql } from 'kysely'
@@ -136,7 +136,7 @@ export declare class CreateTableBuilder<TB extends string, C extends string = ne
136
136
  * )
137
137
  * ```
138
138
  *
139
- * Add constraintfor multiple columns:
139
+ * Add constraint for multiple columns:
140
140
  *
141
141
  * ```ts
142
142
  * addForeignKeyConstraint(
@@ -186,7 +186,7 @@ class CreateTableBuilder {
186
186
  * )
187
187
  * ```
188
188
  *
189
- * Add constraintfor multiple columns:
189
+ * Add constraint for multiple columns:
190
190
  *
191
191
  * ```ts
192
192
  * addForeignKeyConstraint(
@@ -74,7 +74,7 @@ export declare type ExtractColumnType<DB, TB extends keyof DB, C> = {
74
74
  * movie: Movie
75
75
  * }
76
76
  *
77
- * type Columns = AnyColumn<Database, 'person' | 'pet'>
77
+ * type Columns = AnyColumnWithTable<Database, 'person' | 'pet'>
78
78
  *
79
79
  * // Columns == 'person.id' | 'pet.name' | 'pet.species'
80
80
  * ```
@@ -202,4 +202,23 @@ export interface MysqlSslOptions {
202
202
  * You can also connect to a MySQL server without properly providing the appropriate CA to trust. You should not do this.
203
203
  */
204
204
  rejectUnauthorized?: boolean;
205
+ charsetNumber?: number;
206
+ compress?: boolean;
207
+ authSwitchHandler?: (data: any, callback: () => void) => any;
208
+ connectAttributes?: {
209
+ [param: string]: any;
210
+ };
211
+ decimalNumbers?: boolean;
212
+ isServer?: boolean;
213
+ maxPreparedStatements?: number;
214
+ namedPlaceholders?: boolean;
215
+ nestTables?: boolean | string;
216
+ passwordSha1?: string;
217
+ pool?: any;
218
+ stream?: any;
219
+ uri?: string;
220
+ Promise?: any;
221
+ authPlugins?: {
222
+ [key: string]: any;
223
+ };
205
224
  }
@@ -8,5 +8,5 @@ export declare class DefaultConnectionProvider implements ConnectionProvider {
8
8
  * Provides a connection for the callback and takes care of disposing
9
9
  * the connection after the callback has been run.
10
10
  */
11
- provideConnection<T>(runner: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
11
+ provideConnection<T>(consumer: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
12
12
  }
@@ -4,10 +4,10 @@ export class DefaultConnectionProvider {
4
4
  constructor(driver) {
5
5
  this.#driver = driver;
6
6
  }
7
- async provideConnection(runner) {
7
+ async provideConnection(consumer) {
8
8
  const connection = await this.#driver.acquireConnection();
9
9
  try {
10
- return await runner(connection);
10
+ return await consumer(connection);
11
11
  }
12
12
  finally {
13
13
  await this.#driver.releaseConnection(connection);
@@ -27,6 +27,14 @@ import { Driver } from './driver.js';
27
27
  * },
28
28
  * })
29
29
  * ```
30
+ *
31
+ * You can use it to build a query and compile it to SQL but trying to
32
+ * execute the query will throw an error.
33
+ *
34
+ * ```ts
35
+ * const { sql } = db.selectFrom('person').selectAll().compile()
36
+ * console.log(sql) // select * from "person"
37
+ * ```
30
38
  */
31
39
  export declare class DummyDriver implements Driver {
32
40
  /**
@@ -26,6 +26,14 @@
26
26
  * },
27
27
  * })
28
28
  * ```
29
+ *
30
+ * You can use it to build a query and compile it to SQL but trying to
31
+ * execute the query will throw an error.
32
+ *
33
+ * ```ts
34
+ * const { sql } = db.selectFrom('person').selectAll().compile()
35
+ * console.log(sql) // select * from "person"
36
+ * ```
29
37
  */
30
38
  export class DummyDriver {
31
39
  async init() {
@@ -7,5 +7,5 @@ export declare class SingleConnectionProvider implements ConnectionProvider {
7
7
  * Provides a connection for the callback and takes care of disposing
8
8
  * the connection after the callback has been run.
9
9
  */
10
- provideConnection<T>(runner: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
10
+ provideConnection<T>(consumer: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
11
11
  }
@@ -5,11 +5,11 @@ export class SingleConnectionProvider {
5
5
  constructor(connection) {
6
6
  this.#connection = connection;
7
7
  }
8
- async provideConnection(runner) {
8
+ async provideConnection(consumer) {
9
9
  while (this.#runningPromise) {
10
10
  await this.#runningPromise;
11
11
  }
12
- const promise = this.#run(runner);
12
+ const promise = this.#run(consumer);
13
13
  this.#runningPromise = promise
14
14
  .then(() => {
15
15
  this.#runningPromise = undefined;
@@ -1,7 +1,7 @@
1
- import { RawBuilder } from '../index-nodeless.js';
2
1
  import { AliasNode } from '../operation-node/alias-node.js';
3
2
  import { RawNode } from '../operation-node/raw-node.js';
4
3
  import { SelectQueryNode } from '../operation-node/select-query-node.js';
4
+ import { RawBuilder } from '../raw-builder/raw-builder.js';
5
5
  import { AliasedQueryBuilderFactory, AliasedRawBuilderFactory, AnyAliasedQueryBuilder, AnyAliasedRawBuilder, AnySelectQueryBuilder, SelectQueryBuilderFactory, RawBuilderFactory } from '../util/type-utils.js';
6
6
  export declare type ComplexExpression<DB, TB extends keyof DB, V = any> = AnySelectQueryBuilder | SelectQueryBuilderFactory<DB, TB> | RawBuilder<V> | RawBuilderFactory<DB, TB>;
7
7
  export declare type AliasedComplexExpression<DB, TB extends keyof DB> = AnyAliasedQueryBuilder | AliasedQueryBuilderFactory<DB, TB> | AnyAliasedRawBuilder | AliasedRawBuilderFactory<DB, TB>;
@@ -1,6 +1,7 @@
1
- import { DeleteQueryNode, UpdateQueryNode } from '../../index-nodeless.js';
1
+ import { DeleteQueryNode } from '../../operation-node/delete-query-node.js';
2
2
  import { OperationNodeTransformer } from '../../operation-node/operation-node-transformer.js';
3
3
  import { SelectQueryNode } from '../../operation-node/select-query-node.js';
4
+ import { UpdateQueryNode } from '../../operation-node/update-query-node.js';
4
5
  export declare class DeduplicateJoinsTransformer extends OperationNodeTransformer {
5
6
  #private;
6
7
  protected transformSelectQuery(node: SelectQueryNode): SelectQueryNode;
@@ -46,7 +46,13 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
46
46
  * ```
47
47
  *
48
48
  * Operator can be any supported operator or if the typings don't support it
49
- * you can always use `sql\`your operator\``.
49
+ * you can always use
50
+ *
51
+ * ```ts
52
+ * sql`your operator`
53
+ * ```
54
+ *
55
+ * The next example uses the `>` operator:
50
56
  *
51
57
  * ```ts
52
58
  * const persons = await db
@@ -62,8 +68,8 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
62
68
  * select * from "person" where "id" > $1
63
69
  * ```
64
70
  *
65
- * The `where` methods don't change the type of the query. You can add
66
- * conditional `where`s easily by doing something like this:
71
+ * `where` methods don't change the type of the query. You can add
72
+ * conditional statements easily by doing something like this:
67
73
  *
68
74
  * ```ts
69
75
  * let query = db
@@ -71,6 +77,8 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
71
77
  * .selectAll()
72
78
  *
73
79
  * if (firstName) {
80
+ * // The query builder is immutable. Remember to reassign
81
+ * // the result back to the query variable.
74
82
  * query = query.where('first_name', '=', firstName)
75
83
  * }
76
84
  *
@@ -78,8 +86,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
78
86
  * ```
79
87
  *
80
88
  * This is true for basically all methods execpt the `select` and
81
- * `returning` methods, which DO change the return type of the
82
- * query.
89
+ * `returning`, that __do__ change the return type of the query.
83
90
  *
84
91
  * Both the first and third argument can also be subqueries.
85
92
  * A subquery is defined by passing a function and calling
@@ -3,7 +3,7 @@ import { TableExpression, TableExpressionDatabase, TableExpressionTables } from
3
3
  import { FunctionBuilder } from './function-builder.js';
4
4
  import { ExtractTypeFromReferenceExpression, StringReference } from '../parser/reference-parser.js';
5
5
  import { RawBuilder } from '../raw-builder/raw-builder.js';
6
- import { QueryExecutor } from '../index-nodeless.js';
6
+ import { QueryExecutor } from '../query-executor/query-executor.js';
7
7
  export declare class ExpressionBuilder<DB, TB extends keyof DB> {
8
8
  #private;
9
9
  constructor(props: ExpressionBuilderProps);
@@ -7,8 +7,8 @@ import { createQueryId } from '../util/query-id.js';
7
7
  import { FunctionBuilder } from './function-builder.js';
8
8
  import { parseStringReference, } from '../parser/reference-parser.js';
9
9
  import { RawBuilder } from '../raw-builder/raw-builder.js';
10
- import { RawNode } from '../index-nodeless.js';
11
10
  import { freeze } from '../util/object-utils.js';
11
+ import { RawNode } from '../operation-node/raw-node.js';
12
12
  export class ExpressionBuilder {
13
13
  #props;
14
14
  constructor(props) {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./function-builder.d.ts" />
2
- import { RawNode } from '../index-nodeless.js';
2
+ import { RawNode } from '../operation-node/raw-node.js';
3
3
  import { parseStringReference, } from '../parser/reference-parser.js';
4
4
  import { RawBuilder } from '../raw-builder/raw-builder.js';
5
5
  import { createQueryId } from '../util/query-id.js';
@@ -69,7 +69,13 @@ export declare class OnConflictBuilder<DB, TB extends keyof DB> implements Where
69
69
  * ```
70
70
  *
71
71
  * Operator can be any supported operator or if the typings don't support it
72
- * you can always use `sql\`your operator\``.
72
+ * you can always use
73
+ *
74
+ * ```ts
75
+ * sql`your operator`
76
+ * ```
77
+ *
78
+ * The next example uses the `>` operator:
73
79
  *
74
80
  * ```ts
75
81
  * const persons = await db
@@ -85,8 +91,8 @@ export declare class OnConflictBuilder<DB, TB extends keyof DB> implements Where
85
91
  * select * from "person" where "id" > $1
86
92
  * ```
87
93
  *
88
- * The `where` methods don't change the type of the query. You can add
89
- * conditional `where`s easily by doing something like this:
94
+ * `where` methods don't change the type of the query. You can add
95
+ * conditional statements easily by doing something like this:
90
96
  *
91
97
  * ```ts
92
98
  * let query = db
@@ -94,6 +100,8 @@ export declare class OnConflictBuilder<DB, TB extends keyof DB> implements Where
94
100
  * .selectAll()
95
101
  *
96
102
  * if (firstName) {
103
+ * // The query builder is immutable. Remember to reassign
104
+ * // the result back to the query variable.
97
105
  * query = query.where('first_name', '=', firstName)
98
106
  * }
99
107
  *
@@ -101,8 +109,7 @@ export declare class OnConflictBuilder<DB, TB extends keyof DB> implements Where
101
109
  * ```
102
110
  *
103
111
  * This is true for basically all methods execpt the `select` and
104
- * `returning` methods, which DO change the return type of the
105
- * query.
112
+ * `returning`, that __do__ change the return type of the query.
106
113
  *
107
114
  * Both the first and third argument can also be subqueries.
108
115
  * A subquery is defined by passing a function and calling
@@ -426,7 +433,13 @@ export declare class OnConflictUpdateBuilder<DB, TB extends keyof DB> implements
426
433
  * ```
427
434
  *
428
435
  * Operator can be any supported operator or if the typings don't support it
429
- * you can always use `sql\`your operator\``.
436
+ * you can always use
437
+ *
438
+ * ```ts
439
+ * sql`your operator`
440
+ * ```
441
+ *
442
+ * The next example uses the `>` operator:
430
443
  *
431
444
  * ```ts
432
445
  * const persons = await db
@@ -442,8 +455,8 @@ export declare class OnConflictUpdateBuilder<DB, TB extends keyof DB> implements
442
455
  * select * from "person" where "id" > $1
443
456
  * ```
444
457
  *
445
- * The `where` methods don't change the type of the query. You can add
446
- * conditional `where`s easily by doing something like this:
458
+ * `where` methods don't change the type of the query. You can add
459
+ * conditional statements easily by doing something like this:
447
460
  *
448
461
  * ```ts
449
462
  * let query = db
@@ -451,6 +464,8 @@ export declare class OnConflictUpdateBuilder<DB, TB extends keyof DB> implements
451
464
  * .selectAll()
452
465
  *
453
466
  * if (firstName) {
467
+ * // The query builder is immutable. Remember to reassign
468
+ * // the result back to the query variable.
454
469
  * query = query.where('first_name', '=', firstName)
455
470
  * }
456
471
  *
@@ -458,8 +473,7 @@ export declare class OnConflictUpdateBuilder<DB, TB extends keyof DB> implements
458
473
  * ```
459
474
  *
460
475
  * This is true for basically all methods execpt the `select` and
461
- * `returning` methods, which DO change the return type of the
462
- * query.
476
+ * `returning`, that __do__ change the return type of the query.
463
477
  *
464
478
  * Both the first and third argument can also be subqueries.
465
479
  * A subquery is defined by passing a function and calling