kysely 0.17.0 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +19 -0
- package/dist/cjs/driver/connection-provider.d.ts +1 -1
- package/dist/cjs/driver/default-connection-provider.d.ts +1 -1
- package/dist/cjs/driver/default-connection-provider.js +2 -2
- package/dist/cjs/driver/dummy-driver.d.ts +8 -0
- package/dist/cjs/driver/dummy-driver.js +8 -0
- package/dist/cjs/driver/single-connection-provider.d.ts +1 -1
- package/dist/cjs/driver/single-connection-provider.js +2 -2
- package/dist/cjs/kysely.js +23 -29
- package/dist/cjs/parser/complex-expression-parser.d.ts +1 -1
- package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-transformer.d.ts +2 -1
- package/dist/cjs/query-builder/delete-query-builder.d.ts +12 -5
- package/dist/cjs/query-builder/expression-builder.d.ts +1 -1
- package/dist/cjs/query-builder/expression-builder.js +2 -2
- package/dist/cjs/query-builder/function-builder.js +2 -2
- package/dist/cjs/query-builder/on-conflict-builder.d.ts +24 -10
- package/dist/cjs/query-builder/select-query-builder.d.ts +12 -5
- package/dist/cjs/query-builder/update-query-builder.d.ts +12 -5
- package/dist/cjs/query-builder/where-interface.d.ts +12 -5
- package/dist/cjs/query-executor/default-query-executor.d.ts +14 -7
- package/dist/cjs/query-executor/default-query-executor.js +4 -6
- package/dist/cjs/query-executor/noop-query-executor.d.ts +12 -6
- package/dist/cjs/query-executor/noop-query-executor.js +3 -3
- package/dist/cjs/query-executor/query-executor-base.d.ts +62 -0
- package/dist/cjs/query-executor/query-executor-base.js +46 -0
- package/dist/cjs/query-executor/query-executor.d.ts +15 -15
- package/dist/cjs/query-executor/query-executor.js +0 -57
- package/dist/cjs/raw-builder/sql.d.ts +11 -3
- package/dist/cjs/raw-builder/sql.js +10 -2
- package/dist/cjs/schema/alter-table-builder.d.ts +24 -2
- package/dist/cjs/schema/alter-table-builder.js +20 -0
- package/dist/cjs/schema/column-definition-builder.d.ts +4 -2
- package/dist/cjs/schema/create-table-builder.d.ts +1 -1
- package/dist/cjs/schema/create-table-builder.js +1 -1
- package/dist/cjs/util/type-utils.d.ts +1 -1
- package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +19 -0
- package/dist/esm/driver/connection-provider.d.ts +1 -1
- package/dist/esm/driver/default-connection-provider.d.ts +1 -1
- package/dist/esm/driver/default-connection-provider.js +2 -2
- package/dist/esm/driver/dummy-driver.d.ts +8 -0
- package/dist/esm/driver/dummy-driver.js +8 -0
- package/dist/esm/driver/single-connection-provider.d.ts +1 -1
- package/dist/esm/driver/single-connection-provider.js +2 -2
- package/dist/esm/kysely.js +23 -29
- package/dist/esm/parser/complex-expression-parser.d.ts +1 -1
- package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-transformer.d.ts +2 -1
- package/dist/esm/query-builder/delete-query-builder.d.ts +12 -5
- package/dist/esm/query-builder/expression-builder.d.ts +1 -1
- package/dist/esm/query-builder/expression-builder.js +1 -1
- package/dist/esm/query-builder/function-builder.js +1 -1
- package/dist/esm/query-builder/on-conflict-builder.d.ts +24 -10
- package/dist/esm/query-builder/select-query-builder.d.ts +12 -5
- package/dist/esm/query-builder/update-query-builder.d.ts +12 -5
- package/dist/esm/query-builder/where-interface.d.ts +12 -5
- package/dist/esm/query-executor/default-query-executor.d.ts +14 -7
- package/dist/esm/query-executor/default-query-executor.js +4 -6
- package/dist/esm/query-executor/noop-query-executor.d.ts +12 -6
- package/dist/esm/query-executor/noop-query-executor.js +3 -3
- package/dist/esm/query-executor/query-executor-base.d.ts +62 -0
- package/dist/esm/query-executor/query-executor-base.js +43 -0
- package/dist/esm/query-executor/query-executor.d.ts +15 -15
- package/dist/esm/query-executor/query-executor.js +1 -55
- package/dist/esm/raw-builder/sql.d.ts +11 -3
- package/dist/esm/raw-builder/sql.js +10 -2
- package/dist/esm/schema/alter-table-builder.d.ts +24 -2
- package/dist/esm/schema/alter-table-builder.js +20 -0
- package/dist/esm/schema/column-definition-builder.d.ts +4 -2
- package/dist/esm/schema/create-table-builder.d.ts +1 -1
- package/dist/esm/schema/create-table-builder.js +1 -1
- package/dist/esm/util/type-utils.d.ts +1 -1
- package/package.json +9 -9
|
@@ -162,6 +162,25 @@ export interface MysqlDialectConfig {
|
|
|
162
162
|
* If keep-alive is enabled users can supply an initial delay.
|
|
163
163
|
*/
|
|
164
164
|
keepAliveInitialDelay?: number;
|
|
165
|
+
charsetNumber?: number;
|
|
166
|
+
compress?: boolean;
|
|
167
|
+
authSwitchHandler?: (data: any, callback: () => void) => any;
|
|
168
|
+
connectAttributes?: {
|
|
169
|
+
[param: string]: any;
|
|
170
|
+
};
|
|
171
|
+
decimalNumbers?: boolean;
|
|
172
|
+
isServer?: boolean;
|
|
173
|
+
maxPreparedStatements?: number;
|
|
174
|
+
namedPlaceholders?: boolean;
|
|
175
|
+
nestTables?: boolean | string;
|
|
176
|
+
passwordSha1?: string;
|
|
177
|
+
pool?: any;
|
|
178
|
+
stream?: any;
|
|
179
|
+
uri?: string;
|
|
180
|
+
Promise?: any;
|
|
181
|
+
authPlugins?: {
|
|
182
|
+
[key: string]: any;
|
|
183
|
+
};
|
|
165
184
|
/**
|
|
166
185
|
* Called once for each created connection.
|
|
167
186
|
*
|
|
@@ -4,5 +4,5 @@ export interface ConnectionProvider {
|
|
|
4
4
|
* Provides a connection for the callback and takes care of disposing
|
|
5
5
|
* the connection after the callback has been run.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
provideConnection<T>(consumer: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
|
|
8
8
|
}
|
|
@@ -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
|
-
|
|
11
|
+
provideConnection<T>(consumer: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
|
|
12
12
|
}
|
|
@@ -6,10 +6,10 @@ class DefaultConnectionProvider {
|
|
|
6
6
|
constructor(driver) {
|
|
7
7
|
this.#driver = driver;
|
|
8
8
|
}
|
|
9
|
-
async
|
|
9
|
+
async provideConnection(consumer) {
|
|
10
10
|
const connection = await this.#driver.acquireConnection();
|
|
11
11
|
try {
|
|
12
|
-
return await
|
|
12
|
+
return await consumer(connection);
|
|
13
13
|
}
|
|
14
14
|
finally {
|
|
15
15
|
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
|
/**
|
|
@@ -28,6 +28,14 @@ exports.DummyDriver = void 0;
|
|
|
28
28
|
* },
|
|
29
29
|
* })
|
|
30
30
|
* ```
|
|
31
|
+
*
|
|
32
|
+
* You can use it to build a query and compile it to SQL but trying to
|
|
33
|
+
* execute the query will throw an error.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* const { sql } = db.selectFrom('person').selectAll().compile()
|
|
37
|
+
* console.log(sql) // select * from "person"
|
|
38
|
+
* ```
|
|
31
39
|
*/
|
|
32
40
|
class DummyDriver {
|
|
33
41
|
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
|
-
|
|
10
|
+
provideConnection<T>(consumer: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
|
|
11
11
|
}
|
|
@@ -7,11 +7,11 @@ class SingleConnectionProvider {
|
|
|
7
7
|
constructor(connection) {
|
|
8
8
|
this.#connection = connection;
|
|
9
9
|
}
|
|
10
|
-
async
|
|
10
|
+
async provideConnection(consumer) {
|
|
11
11
|
while (this.#runningPromise) {
|
|
12
12
|
await this.#runningPromise;
|
|
13
13
|
}
|
|
14
|
-
const promise = this.#run(
|
|
14
|
+
const promise = this.#run(consumer);
|
|
15
15
|
this.#runningPromise = promise
|
|
16
16
|
.then(() => {
|
|
17
17
|
this.#runningPromise = undefined;
|
package/dist/cjs/kysely.js
CHANGED
|
@@ -338,18 +338,14 @@ class ConnectionBuilder {
|
|
|
338
338
|
this.#props = (0, object_utils_js_1.freeze)(props);
|
|
339
339
|
}
|
|
340
340
|
async execute(callback) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
try {
|
|
341
|
+
return this.#props.executor.provideConnection(async (connection) => {
|
|
342
|
+
const executor = this.#props.executor.withConnectionProvider(new single_connection_provider_js_1.SingleConnectionProvider(connection));
|
|
343
|
+
const db = new Kysely({
|
|
344
|
+
...this.#props,
|
|
345
|
+
executor,
|
|
346
|
+
});
|
|
348
347
|
return await callback(db);
|
|
349
|
-
}
|
|
350
|
-
finally {
|
|
351
|
-
await this.#props.driver.releaseConnection(connection);
|
|
352
|
-
}
|
|
348
|
+
});
|
|
353
349
|
}
|
|
354
350
|
}
|
|
355
351
|
exports.ConnectionBuilder = ConnectionBuilder;
|
|
@@ -369,25 +365,23 @@ class TransactionBuilder {
|
|
|
369
365
|
const { isolationLevel, ...kyselyProps } = this.#props;
|
|
370
366
|
const settings = { isolationLevel };
|
|
371
367
|
validateTransactionSettings(settings);
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
368
|
+
return this.#props.executor.provideConnection(async (connection) => {
|
|
369
|
+
const executor = this.#props.executor.withConnectionProvider(new single_connection_provider_js_1.SingleConnectionProvider(connection));
|
|
370
|
+
const transaction = new Transaction({
|
|
371
|
+
...kyselyProps,
|
|
372
|
+
executor,
|
|
373
|
+
});
|
|
374
|
+
try {
|
|
375
|
+
await this.#props.driver.beginTransaction(connection, settings);
|
|
376
|
+
const result = await callback(transaction);
|
|
377
|
+
await this.#props.driver.commitTransaction(connection);
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
await this.#props.driver.rollbackTransaction(connection);
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
377
384
|
});
|
|
378
|
-
try {
|
|
379
|
-
await this.#props.driver.beginTransaction(connection, settings);
|
|
380
|
-
const result = await callback(transaction);
|
|
381
|
-
await this.#props.driver.commitTransaction(connection);
|
|
382
|
-
return result;
|
|
383
|
-
}
|
|
384
|
-
catch (error) {
|
|
385
|
-
await this.#props.driver.rollbackTransaction(connection);
|
|
386
|
-
throw error;
|
|
387
|
-
}
|
|
388
|
-
finally {
|
|
389
|
-
await this.#props.driver.releaseConnection(connection);
|
|
390
|
-
}
|
|
391
385
|
}
|
|
392
386
|
}
|
|
393
387
|
exports.TransactionBuilder = TransactionBuilder;
|
|
@@ -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
|
|
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
|
|
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
|
-
*
|
|
66
|
-
* conditional
|
|
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
|
|
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 '../
|
|
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);
|
|
@@ -9,8 +9,8 @@ const query_id_js_1 = require("../util/query-id.js");
|
|
|
9
9
|
const function_builder_js_1 = require("./function-builder.js");
|
|
10
10
|
const reference_parser_js_1 = require("../parser/reference-parser.js");
|
|
11
11
|
const raw_builder_js_1 = require("../raw-builder/raw-builder.js");
|
|
12
|
-
const index_nodeless_js_1 = require("../index-nodeless.js");
|
|
13
12
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
13
|
+
const raw_node_js_1 = require("../operation-node/raw-node.js");
|
|
14
14
|
class ExpressionBuilder {
|
|
15
15
|
#props;
|
|
16
16
|
constructor(props) {
|
|
@@ -100,7 +100,7 @@ class ExpressionBuilder {
|
|
|
100
100
|
return new raw_builder_js_1.RawBuilder({
|
|
101
101
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
102
102
|
plugins: this.#props.executor.plugins,
|
|
103
|
-
rawNode:
|
|
103
|
+
rawNode: raw_node_js_1.RawNode.createWithChild((0, reference_parser_js_1.parseStringReference)(reference)),
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FunctionBuilder = void 0;
|
|
4
|
-
const
|
|
4
|
+
const raw_node_js_1 = require("../operation-node/raw-node.js");
|
|
5
5
|
const reference_parser_js_1 = require("../parser/reference-parser.js");
|
|
6
6
|
const raw_builder_js_1 = require("../raw-builder/raw-builder.js");
|
|
7
7
|
const query_id_js_1 = require("../util/query-id.js");
|
|
@@ -153,7 +153,7 @@ class FunctionBuilder {
|
|
|
153
153
|
#oneArgFunction(fn, column) {
|
|
154
154
|
return new raw_builder_js_1.RawBuilder({
|
|
155
155
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
156
|
-
rawNode:
|
|
156
|
+
rawNode: raw_node_js_1.RawNode.create([`${fn}(`, ')'], [(0, reference_parser_js_1.parseStringReference)(column)]),
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -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
|
|
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
|
-
*
|
|
89
|
-
* conditional
|
|
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
|
|
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
|
|
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
|
-
*
|
|
446
|
-
* conditional
|
|
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
|
|
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
|
|
@@ -45,7 +45,13 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
45
45
|
* ```
|
|
46
46
|
*
|
|
47
47
|
* Operator can be any supported operator or if the typings don't support it
|
|
48
|
-
* you can always use
|
|
48
|
+
* you can always use
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* sql`your operator`
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* The next example uses the `>` operator:
|
|
49
55
|
*
|
|
50
56
|
* ```ts
|
|
51
57
|
* const persons = await db
|
|
@@ -61,8 +67,8 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
61
67
|
* select * from "person" where "id" > $1
|
|
62
68
|
* ```
|
|
63
69
|
*
|
|
64
|
-
*
|
|
65
|
-
* conditional
|
|
70
|
+
* `where` methods don't change the type of the query. You can add
|
|
71
|
+
* conditional statements easily by doing something like this:
|
|
66
72
|
*
|
|
67
73
|
* ```ts
|
|
68
74
|
* let query = db
|
|
@@ -70,6 +76,8 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
70
76
|
* .selectAll()
|
|
71
77
|
*
|
|
72
78
|
* if (firstName) {
|
|
79
|
+
* // The query builder is immutable. Remember to reassign
|
|
80
|
+
* // the result back to the query variable.
|
|
73
81
|
* query = query.where('first_name', '=', firstName)
|
|
74
82
|
* }
|
|
75
83
|
*
|
|
@@ -77,8 +85,7 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
77
85
|
* ```
|
|
78
86
|
*
|
|
79
87
|
* This is true for basically all methods execpt the `select` and
|
|
80
|
-
* `returning
|
|
81
|
-
* query.
|
|
88
|
+
* `returning`, that __do__ change the return type of the query.
|
|
82
89
|
*
|
|
83
90
|
* Both the first and third argument can also be subqueries.
|
|
84
91
|
* A subquery is defined by passing a function and calling
|
|
@@ -46,7 +46,13 @@ export declare class UpdateQueryBuilder<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
|
|
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 UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
62
68
|
* select * from "person" where "id" > $1
|
|
63
69
|
* ```
|
|
64
70
|
*
|
|
65
|
-
*
|
|
66
|
-
* conditional
|
|
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 UpdateQueryBuilder<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 UpdateQueryBuilder<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
|
|
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
|
|
@@ -26,7 +26,13 @@ export interface WhereInterface<DB, TB extends keyof DB> {
|
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
28
|
* Operator can be any supported operator or if the typings don't support it
|
|
29
|
-
* you can always use
|
|
29
|
+
* you can always use
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* sql`your operator`
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* The next example uses the `>` operator:
|
|
30
36
|
*
|
|
31
37
|
* ```ts
|
|
32
38
|
* const persons = await db
|
|
@@ -42,8 +48,8 @@ export interface WhereInterface<DB, TB extends keyof DB> {
|
|
|
42
48
|
* select * from "person" where "id" > $1
|
|
43
49
|
* ```
|
|
44
50
|
*
|
|
45
|
-
*
|
|
46
|
-
* conditional
|
|
51
|
+
* `where` methods don't change the type of the query. You can add
|
|
52
|
+
* conditional statements easily by doing something like this:
|
|
47
53
|
*
|
|
48
54
|
* ```ts
|
|
49
55
|
* let query = db
|
|
@@ -51,6 +57,8 @@ export interface WhereInterface<DB, TB extends keyof DB> {
|
|
|
51
57
|
* .selectAll()
|
|
52
58
|
*
|
|
53
59
|
* if (firstName) {
|
|
60
|
+
* // The query builder is immutable. Remember to reassign
|
|
61
|
+
* // the result back to the query variable.
|
|
54
62
|
* query = query.where('first_name', '=', firstName)
|
|
55
63
|
* }
|
|
56
64
|
*
|
|
@@ -58,8 +66,7 @@ export interface WhereInterface<DB, TB extends keyof DB> {
|
|
|
58
66
|
* ```
|
|
59
67
|
*
|
|
60
68
|
* This is true for basically all methods execpt the `select` and
|
|
61
|
-
* `returning
|
|
62
|
-
* query.
|
|
69
|
+
* `returning`, that __do__ change the return type of the query.
|
|
63
70
|
*
|
|
64
71
|
* Both the first and third argument can also be subqueries.
|
|
65
72
|
* A subquery is defined by passing a function and calling
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { ConnectionProvider } from '../driver/connection-provider.js';
|
|
2
|
-
import {
|
|
2
|
+
import { DatabaseConnection } from '../driver/database-connection.js';
|
|
3
3
|
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
4
4
|
import { RootOperationNode, QueryCompiler } from '../query-compiler/query-compiler.js';
|
|
5
5
|
import { KyselyPlugin } from '../plugin/kysely-plugin.js';
|
|
6
|
-
import {
|
|
7
|
-
import { DialectAdapter } from '../
|
|
8
|
-
export declare class DefaultQueryExecutor extends
|
|
6
|
+
import { QueryExecutorBase } from './query-executor-base.js';
|
|
7
|
+
import { DialectAdapter } from '../dialect/dialect-adapter.js';
|
|
8
|
+
export declare class DefaultQueryExecutor extends QueryExecutorBase {
|
|
9
9
|
#private;
|
|
10
10
|
constructor(compiler: QueryCompiler, adapter: DialectAdapter, connectionProvider: ConnectionProvider, plugins?: KyselyPlugin[]);
|
|
11
|
+
/**
|
|
12
|
+
* Returns the adapter for the current dialect.
|
|
13
|
+
*/
|
|
11
14
|
get adapter(): DialectAdapter;
|
|
12
15
|
/**
|
|
13
16
|
* Compiles the transformed query into SQL. You usually want to pass
|
|
@@ -15,7 +18,11 @@ export declare class DefaultQueryExecutor extends QueryExecutor {
|
|
|
15
18
|
* compile any query using this method.
|
|
16
19
|
*/
|
|
17
20
|
compileQuery(node: RootOperationNode): CompiledQuery;
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Provides a connection for the callback and takes care of disposing
|
|
23
|
+
* the connection after the callback has been run.
|
|
24
|
+
*/
|
|
25
|
+
provideConnection<T>(consumer: (connection: DatabaseConnection) => Promise<T>): Promise<T>;
|
|
19
26
|
/**
|
|
20
27
|
* Returns a copy of this executor with a list of plugins added
|
|
21
28
|
* as the last plugins.
|
|
@@ -34,9 +41,9 @@ export declare class DefaultQueryExecutor extends QueryExecutor {
|
|
|
34
41
|
/**
|
|
35
42
|
* Returns a copy of this executor with a new connection provider.
|
|
36
43
|
*/
|
|
37
|
-
withConnectionProvider(connectionProvider: ConnectionProvider):
|
|
44
|
+
withConnectionProvider(connectionProvider: ConnectionProvider): DefaultQueryExecutor;
|
|
38
45
|
/**
|
|
39
46
|
* Returns a copy of this executor without any plugins.
|
|
40
47
|
*/
|
|
41
|
-
withoutPlugins():
|
|
48
|
+
withoutPlugins(): DefaultQueryExecutor;
|
|
42
49
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultQueryExecutor = void 0;
|
|
4
|
-
const
|
|
5
|
-
class DefaultQueryExecutor extends
|
|
4
|
+
const query_executor_base_js_1 = require("./query-executor-base.js");
|
|
5
|
+
class DefaultQueryExecutor extends query_executor_base_js_1.QueryExecutorBase {
|
|
6
6
|
#compiler;
|
|
7
7
|
#adapter;
|
|
8
8
|
#connectionProvider;
|
|
@@ -18,10 +18,8 @@ class DefaultQueryExecutor extends query_executor_js_1.QueryExecutor {
|
|
|
18
18
|
compileQuery(node) {
|
|
19
19
|
return this.#compiler.compileQuery(node);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
return this.#connectionProvider.
|
|
23
|
-
return connection.executeQuery(compiledQuery);
|
|
24
|
-
});
|
|
21
|
+
provideConnection(consumer) {
|
|
22
|
+
return this.#connectionProvider.provideConnection(consumer);
|
|
25
23
|
}
|
|
26
24
|
withPlugins(plugins) {
|
|
27
25
|
return new DefaultQueryExecutor(this.#compiler, this.#adapter, this.#connectionProvider, [...this.plugins, ...plugins]);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { QueryResult } from '../driver/database-connection.js';
|
|
2
1
|
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
3
|
-
import { QueryExecutor } from './query-executor.js';
|
|
4
2
|
import { KyselyPlugin } from '../plugin/kysely-plugin.js';
|
|
5
3
|
import { DialectAdapter } from '../dialect/dialect-adapter.js';
|
|
4
|
+
import { QueryExecutorBase } from './query-executor-base.js';
|
|
6
5
|
/**
|
|
7
6
|
* A {@link QueryExecutor} subclass that can be used when you don't
|
|
8
7
|
* have a {@link QueryCompiler}, {@link ConnectionProvider} or any
|
|
9
8
|
* other needed things to actually execute queries.
|
|
10
9
|
*/
|
|
11
|
-
export declare class NoopQueryExecutor extends
|
|
10
|
+
export declare class NoopQueryExecutor extends QueryExecutorBase {
|
|
11
|
+
/**
|
|
12
|
+
* Returns the adapter for the current dialect.
|
|
13
|
+
*/
|
|
12
14
|
get adapter(): DialectAdapter;
|
|
13
15
|
/**
|
|
14
16
|
* Compiles the transformed query into SQL. You usually want to pass
|
|
@@ -16,11 +18,15 @@ export declare class NoopQueryExecutor extends QueryExecutor {
|
|
|
16
18
|
* compile any query using this method.
|
|
17
19
|
*/
|
|
18
20
|
compileQuery(): CompiledQuery;
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Provides a connection for the callback and takes care of disposing
|
|
23
|
+
* the connection after the callback has been run.
|
|
24
|
+
*/
|
|
25
|
+
provideConnection<T>(): Promise<T>;
|
|
20
26
|
/**
|
|
21
27
|
* Returns a copy of this executor with a new connection provider.
|
|
22
28
|
*/
|
|
23
|
-
withConnectionProvider():
|
|
29
|
+
withConnectionProvider(): NoopQueryExecutor;
|
|
24
30
|
/**
|
|
25
31
|
* Returns a copy of this executor with a plugin added as the
|
|
26
32
|
* last plugin.
|
|
@@ -39,6 +45,6 @@ export declare class NoopQueryExecutor extends QueryExecutor {
|
|
|
39
45
|
/**
|
|
40
46
|
* Returns a copy of this executor without any plugins.
|
|
41
47
|
*/
|
|
42
|
-
withoutPlugins():
|
|
48
|
+
withoutPlugins(): NoopQueryExecutor;
|
|
43
49
|
}
|
|
44
50
|
export declare const NOOP_QUERY_EXECUTOR: NoopQueryExecutor;
|