kysely 0.27.0 → 0.27.1
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 +2 -2
- package/dist/cjs/dialect/mssql/mssql-introspector.js +8 -6
- package/dist/cjs/expression/expression-wrapper.d.ts +13 -3
- package/dist/cjs/expression/expression-wrapper.js +12 -0
- package/dist/cjs/operation-node/insert-query-node.d.ts +1 -0
- package/dist/cjs/operation-node/limit-node.d.ts +2 -3
- package/dist/cjs/operation-node/limit-node.js +1 -2
- package/dist/cjs/operation-node/offset-node.d.ts +2 -3
- package/dist/cjs/operation-node/offset-node.js +1 -2
- package/dist/cjs/operation-node/operation-node-transformer.js +2 -0
- package/dist/cjs/operation-node/select-modifier-node.d.ts +2 -1
- package/dist/cjs/operation-node/select-modifier-node.js +2 -1
- package/dist/cjs/query-builder/aggregate-function-builder.d.ts +17 -0
- package/dist/cjs/query-builder/aggregate-function-builder.js +21 -0
- package/dist/cjs/query-builder/case-builder.d.ts +2 -2
- package/dist/cjs/query-builder/delete-query-builder.d.ts +5 -4
- package/dist/cjs/query-builder/delete-query-builder.js +4 -3
- package/dist/cjs/query-builder/function-module.d.ts +1 -1
- package/dist/cjs/query-builder/insert-query-builder.d.ts +7 -3
- package/dist/cjs/query-builder/insert-query-builder.js +13 -2
- package/dist/cjs/query-builder/json-path-builder.d.ts +2 -1
- package/dist/cjs/query-builder/json-path-builder.js +3 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +11 -9
- package/dist/cjs/query-builder/select-query-builder.js +12 -10
- package/dist/cjs/query-builder/update-query-builder.d.ts +3 -3
- package/dist/cjs/query-builder/update-query-builder.js +2 -2
- package/dist/cjs/query-compiler/default-query-compiler.js +8 -0
- package/dist/cjs/raw-builder/raw-builder.d.ts +11 -1
- package/dist/cjs/raw-builder/raw-builder.js +3 -0
- package/dist/cjs/raw-builder/sql.js +9 -2
- package/dist/cjs/util/object-utils.d.ts +1 -1
- package/dist/cjs/util/object-utils.js +1 -1
- package/dist/esm/dialect/mssql/mssql-introspector.js +8 -6
- package/dist/esm/expression/expression-wrapper.d.ts +13 -3
- package/dist/esm/expression/expression-wrapper.js +12 -0
- package/dist/esm/operation-node/insert-query-node.d.ts +1 -0
- package/dist/esm/operation-node/limit-node.d.ts +2 -3
- package/dist/esm/operation-node/limit-node.js +1 -2
- package/dist/esm/operation-node/offset-node.d.ts +2 -3
- package/dist/esm/operation-node/offset-node.js +1 -2
- package/dist/esm/operation-node/operation-node-transformer.js +2 -0
- package/dist/esm/operation-node/select-modifier-node.d.ts +2 -1
- package/dist/esm/operation-node/select-modifier-node.js +2 -1
- package/dist/esm/query-builder/aggregate-function-builder.d.ts +17 -0
- package/dist/esm/query-builder/aggregate-function-builder.js +21 -0
- package/dist/esm/query-builder/case-builder.d.ts +2 -2
- package/dist/esm/query-builder/delete-query-builder.d.ts +5 -4
- package/dist/esm/query-builder/delete-query-builder.js +4 -3
- package/dist/esm/query-builder/function-module.d.ts +1 -1
- package/dist/esm/query-builder/insert-query-builder.d.ts +7 -3
- package/dist/esm/query-builder/insert-query-builder.js +13 -2
- package/dist/esm/query-builder/json-path-builder.d.ts +2 -1
- package/dist/esm/query-builder/json-path-builder.js +3 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +11 -9
- package/dist/esm/query-builder/select-query-builder.js +13 -11
- package/dist/esm/query-builder/update-query-builder.d.ts +3 -3
- package/dist/esm/query-builder/update-query-builder.js +2 -2
- package/dist/esm/query-compiler/default-query-compiler.js +8 -0
- package/dist/esm/raw-builder/raw-builder.d.ts +11 -1
- package/dist/esm/raw-builder/raw-builder.js +3 -0
- package/dist/esm/raw-builder/sql.js +9 -2
- package/dist/esm/util/object-utils.d.ts +1 -1
- package/dist/esm/util/object-utils.js +1 -1
- package/package.json +5 -11
|
@@ -130,7 +130,17 @@ export interface RawBuilder<O> extends AliasableExpression<O> {
|
|
|
130
130
|
* This method call doesn't change the SQL in any way. This methods simply
|
|
131
131
|
* returns a copy of this `RawBuilder` with a new output type.
|
|
132
132
|
*/
|
|
133
|
-
$castTo<
|
|
133
|
+
$castTo<C>(): RawBuilder<C>;
|
|
134
|
+
/**
|
|
135
|
+
* Omit null from the expression's type.
|
|
136
|
+
*
|
|
137
|
+
* This function can be useful in cases where you know an expression can't be
|
|
138
|
+
* null, but Kysely is unable to infer it.
|
|
139
|
+
*
|
|
140
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
141
|
+
* returns a copy of `this` with a new output type.
|
|
142
|
+
*/
|
|
143
|
+
$notNull(): RawBuilder<Exclude<O, null>>;
|
|
134
144
|
/**
|
|
135
145
|
* Adds a plugin for this SQL snippet.
|
|
136
146
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sql = void 0;
|
|
4
4
|
const identifier_node_js_1 = require("../operation-node/identifier-node.js");
|
|
5
|
+
const operation_node_source_js_1 = require("../operation-node/operation-node-source.js");
|
|
5
6
|
const raw_node_js_1 = require("../operation-node/raw-node.js");
|
|
6
7
|
const value_node_js_1 = require("../operation-node/value-node.js");
|
|
7
8
|
const reference_parser_js_1 = require("../parser/reference-parser.js");
|
|
@@ -12,7 +13,7 @@ const raw_builder_js_1 = require("./raw-builder.js");
|
|
|
12
13
|
exports.sql = Object.assign((sqlFragments, ...parameters) => {
|
|
13
14
|
return (0, raw_builder_js_1.createRawBuilder)({
|
|
14
15
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
15
|
-
rawNode: raw_node_js_1.RawNode.create(sqlFragments, parameters?.map(
|
|
16
|
+
rawNode: raw_node_js_1.RawNode.create(sqlFragments, parameters?.map(parseParameter) ?? []),
|
|
16
17
|
});
|
|
17
18
|
}, {
|
|
18
19
|
ref(columnReference) {
|
|
@@ -64,7 +65,7 @@ exports.sql = Object.assign((sqlFragments, ...parameters) => {
|
|
|
64
65
|
const nodes = new Array(2 * array.length - 1);
|
|
65
66
|
const sep = separator.toOperationNode();
|
|
66
67
|
for (let i = 0; i < array.length; ++i) {
|
|
67
|
-
nodes[2 * i] = (
|
|
68
|
+
nodes[2 * i] = parseParameter(array[i]);
|
|
68
69
|
if (i !== array.length - 1) {
|
|
69
70
|
nodes[2 * i + 1] = sep;
|
|
70
71
|
}
|
|
@@ -75,3 +76,9 @@ exports.sql = Object.assign((sqlFragments, ...parameters) => {
|
|
|
75
76
|
});
|
|
76
77
|
},
|
|
77
78
|
});
|
|
79
|
+
function parseParameter(param) {
|
|
80
|
+
if ((0, operation_node_source_js_1.isOperationNodeSource)(param)) {
|
|
81
|
+
return param.toOperationNode();
|
|
82
|
+
}
|
|
83
|
+
return (0, value_parser_js_1.parseValueExpression)(param);
|
|
84
|
+
}
|
|
@@ -16,7 +16,7 @@ export declare function isArrayBufferOrView(obj: unknown): obj is ArrayBuffer |
|
|
|
16
16
|
export declare function isPlainObject(obj: unknown): obj is Record<string, unknown>;
|
|
17
17
|
export declare function getLast<T>(arr: ArrayLike<T>): T | undefined;
|
|
18
18
|
export declare function freeze<T>(obj: T): Readonly<T>;
|
|
19
|
-
export declare function asArray<T>(arg: T | T
|
|
19
|
+
export declare function asArray<T>(arg: T | ReadonlyArray<T>): ReadonlyArray<T>;
|
|
20
20
|
export declare function asReadonlyArray<T>(arg: T | ReadonlyArray<T>): ReadonlyArray<T>;
|
|
21
21
|
export declare function isReadonlyArray(arg: unknown): arg is ReadonlyArray<unknown>;
|
|
22
22
|
export declare function noop<T>(obj: T): T;
|
|
@@ -65,12 +65,14 @@ export class MssqlIntrospector {
|
|
|
65
65
|
const tableDictionary = {};
|
|
66
66
|
for (const rawColumn of rawColumns) {
|
|
67
67
|
const key = `${rawColumn.table_schema_name}.${rawColumn.table_name}`;
|
|
68
|
-
const table = (tableDictionary[key]
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
const table = (tableDictionary[key] =
|
|
69
|
+
tableDictionary[key] ||
|
|
70
|
+
freeze({
|
|
71
|
+
columns: [],
|
|
72
|
+
isView: rawColumn.table_type === 'V ',
|
|
73
|
+
name: rawColumn.table_name,
|
|
74
|
+
schema: rawColumn.table_schema_name ?? undefined,
|
|
75
|
+
}));
|
|
74
76
|
table.columns.push(freeze({
|
|
75
77
|
dataType: rawColumn.type_name,
|
|
76
78
|
dataTypeSchema: rawColumn.type_schema_name ?? undefined,
|
|
@@ -243,7 +243,17 @@ export declare class ExpressionWrapper<DB, TB extends keyof DB, T> implements Al
|
|
|
243
243
|
* This method call doesn't change the SQL in any way. This methods simply
|
|
244
244
|
* returns a copy of this `ExpressionWrapper` with a new output type.
|
|
245
245
|
*/
|
|
246
|
-
$castTo<
|
|
246
|
+
$castTo<C>(): ExpressionWrapper<DB, TB, C>;
|
|
247
|
+
/**
|
|
248
|
+
* Omit null from the expression's type.
|
|
249
|
+
*
|
|
250
|
+
* This function can be useful in cases where you know an expression can't be
|
|
251
|
+
* null, but Kysely is unable to infer it.
|
|
252
|
+
*
|
|
253
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
254
|
+
* returns a copy of `this` with a new output type.
|
|
255
|
+
*/
|
|
256
|
+
$notNull(): ExpressionWrapper<DB, TB, Exclude<T, null>>;
|
|
247
257
|
/**
|
|
248
258
|
* Creates the OperationNode that describes how to compile this expression into SQL.
|
|
249
259
|
*
|
|
@@ -397,7 +407,7 @@ export declare class OrWrapper<DB, TB extends keyof DB, T extends SqlBool> imple
|
|
|
397
407
|
* This method call doesn't change the SQL in any way. This methods simply
|
|
398
408
|
* returns a copy of this `OrWrapper` with a new output type.
|
|
399
409
|
*/
|
|
400
|
-
$castTo<
|
|
410
|
+
$castTo<C extends SqlBool>(): OrWrapper<DB, TB, C>;
|
|
401
411
|
/**
|
|
402
412
|
* Creates the OperationNode that describes how to compile this expression into SQL.
|
|
403
413
|
*
|
|
@@ -533,7 +543,7 @@ export declare class AndWrapper<DB, TB extends keyof DB, T extends SqlBool> impl
|
|
|
533
543
|
* This method call doesn't change the SQL in any way. This methods simply
|
|
534
544
|
* returns a copy of this `AndWrapper` with a new output type.
|
|
535
545
|
*/
|
|
536
|
-
$castTo<
|
|
546
|
+
$castTo<C extends SqlBool>(): AndWrapper<DB, TB, C>;
|
|
537
547
|
/**
|
|
538
548
|
* Creates the OperationNode that describes how to compile this expression into SQL.
|
|
539
549
|
*
|
|
@@ -33,6 +33,18 @@ export class ExpressionWrapper {
|
|
|
33
33
|
$castTo() {
|
|
34
34
|
return new ExpressionWrapper(this.#node);
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Omit null from the expression's type.
|
|
38
|
+
*
|
|
39
|
+
* This function can be useful in cases where you know an expression can't be
|
|
40
|
+
* null, but Kysely is unable to infer it.
|
|
41
|
+
*
|
|
42
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
43
|
+
* returns a copy of `this` with a new output type.
|
|
44
|
+
*/
|
|
45
|
+
$notNull() {
|
|
46
|
+
return new ExpressionWrapper(this.#node);
|
|
47
|
+
}
|
|
36
48
|
toOperationNode() {
|
|
37
49
|
return this.#node;
|
|
38
50
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node.js';
|
|
2
|
-
import { ValueNode } from './value-node.js';
|
|
3
2
|
export interface LimitNode extends OperationNode {
|
|
4
3
|
readonly kind: 'LimitNode';
|
|
5
|
-
readonly limit:
|
|
4
|
+
readonly limit: OperationNode;
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
7
|
* @internal
|
|
9
8
|
*/
|
|
10
9
|
export declare const LimitNode: Readonly<{
|
|
11
10
|
is(node: OperationNode): node is LimitNode;
|
|
12
|
-
create(limit:
|
|
11
|
+
create(limit: OperationNode): LimitNode;
|
|
13
12
|
}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="./limit-node.d.ts" />
|
|
2
2
|
import { freeze } from '../util/object-utils.js';
|
|
3
|
-
import { ValueNode } from './value-node.js';
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
@@ -11,7 +10,7 @@ export const LimitNode = freeze({
|
|
|
11
10
|
create(limit) {
|
|
12
11
|
return freeze({
|
|
13
12
|
kind: 'LimitNode',
|
|
14
|
-
limit
|
|
13
|
+
limit,
|
|
15
14
|
});
|
|
16
15
|
},
|
|
17
16
|
});
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node.js';
|
|
2
|
-
import { ValueNode } from './value-node.js';
|
|
3
2
|
export interface OffsetNode extends OperationNode {
|
|
4
3
|
readonly kind: 'OffsetNode';
|
|
5
|
-
readonly offset:
|
|
4
|
+
readonly offset: OperationNode;
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
7
|
* @internal
|
|
9
8
|
*/
|
|
10
9
|
export declare const OffsetNode: Readonly<{
|
|
11
10
|
is(node: OperationNode): node is OffsetNode;
|
|
12
|
-
create(offset:
|
|
11
|
+
create(offset: OperationNode): OffsetNode;
|
|
13
12
|
}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="./offset-node.d.ts" />
|
|
2
2
|
import { freeze } from '../util/object-utils.js';
|
|
3
|
-
import { ValueNode } from './value-node.js';
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
@@ -11,7 +10,7 @@ export const OffsetNode = freeze({
|
|
|
11
10
|
create(offset) {
|
|
12
11
|
return freeze({
|
|
13
12
|
kind: 'OffsetNode',
|
|
14
|
-
offset
|
|
13
|
+
offset,
|
|
15
14
|
});
|
|
16
15
|
},
|
|
17
16
|
});
|
|
@@ -257,6 +257,7 @@ export class OperationNodeTransformer {
|
|
|
257
257
|
ignore: node.ignore,
|
|
258
258
|
replace: node.replace,
|
|
259
259
|
explain: this.transformNode(node.explain),
|
|
260
|
+
defaultValues: node.defaultValues,
|
|
260
261
|
});
|
|
261
262
|
}
|
|
262
263
|
transformValues(node) {
|
|
@@ -633,6 +634,7 @@ export class OperationNodeTransformer {
|
|
|
633
634
|
kind: 'SelectModifierNode',
|
|
634
635
|
modifier: node.modifier,
|
|
635
636
|
rawModifier: this.transformNode(node.rawModifier),
|
|
637
|
+
of: this.transformNodeList(node.of),
|
|
636
638
|
});
|
|
637
639
|
}
|
|
638
640
|
transformCreateType(node) {
|
|
@@ -4,12 +4,13 @@ export interface SelectModifierNode extends OperationNode {
|
|
|
4
4
|
readonly kind: 'SelectModifierNode';
|
|
5
5
|
readonly modifier?: SelectModifier;
|
|
6
6
|
readonly rawModifier?: OperationNode;
|
|
7
|
+
readonly of?: ReadonlyArray<OperationNode>;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* @internal
|
|
10
11
|
*/
|
|
11
12
|
export declare const SelectModifierNode: Readonly<{
|
|
12
13
|
is(node: OperationNode): node is SelectModifierNode;
|
|
13
|
-
create(modifier: SelectModifier): SelectModifierNode;
|
|
14
|
+
create(modifier: SelectModifier, of?: ReadonlyArray<OperationNode>): SelectModifierNode;
|
|
14
15
|
createWithExpression(modifier: OperationNode): SelectModifierNode;
|
|
15
16
|
}>;
|
|
@@ -7,10 +7,11 @@ export const SelectModifierNode = freeze({
|
|
|
7
7
|
is(node) {
|
|
8
8
|
return node.kind === 'SelectModifierNode';
|
|
9
9
|
},
|
|
10
|
-
create(modifier) {
|
|
10
|
+
create(modifier, of) {
|
|
11
11
|
return freeze({
|
|
12
12
|
kind: 'SelectModifierNode',
|
|
13
13
|
modifier,
|
|
14
|
+
of,
|
|
14
15
|
});
|
|
15
16
|
},
|
|
16
17
|
createWithExpression(modifier) {
|
|
@@ -199,6 +199,23 @@ export declare class AggregateFunctionBuilder<DB, TB extends keyof DB, O = unkno
|
|
|
199
199
|
* what the provided function returns.
|
|
200
200
|
*/
|
|
201
201
|
$call<T>(func: (qb: this) => T): T;
|
|
202
|
+
/**
|
|
203
|
+
* Casts the expression to the given type.
|
|
204
|
+
*
|
|
205
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
206
|
+
* returns a copy of this `AggregateFunctionBuilder` with a new output type.
|
|
207
|
+
*/
|
|
208
|
+
$castTo<C>(): AggregateFunctionBuilder<DB, TB, C>;
|
|
209
|
+
/**
|
|
210
|
+
* Omit null from the expression's type.
|
|
211
|
+
*
|
|
212
|
+
* This function can be useful in cases where you know an expression can't be
|
|
213
|
+
* null, but Kysely is unable to infer it.
|
|
214
|
+
*
|
|
215
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
216
|
+
* returns a copy of `this` with a new output type.
|
|
217
|
+
*/
|
|
218
|
+
$notNull(): AggregateFunctionBuilder<DB, TB, Exclude<O, null>>;
|
|
202
219
|
/**
|
|
203
220
|
* Creates the OperationNode that describes how to compile this expression into SQL.
|
|
204
221
|
*
|
|
@@ -170,6 +170,27 @@ export class AggregateFunctionBuilder {
|
|
|
170
170
|
$call(func) {
|
|
171
171
|
return func(this);
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Casts the expression to the given type.
|
|
175
|
+
*
|
|
176
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
177
|
+
* returns a copy of this `AggregateFunctionBuilder` with a new output type.
|
|
178
|
+
*/
|
|
179
|
+
$castTo() {
|
|
180
|
+
return new AggregateFunctionBuilder(this.#props);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Omit null from the expression's type.
|
|
184
|
+
*
|
|
185
|
+
* This function can be useful in cases where you know an expression can't be
|
|
186
|
+
* null, but Kysely is unable to infer it.
|
|
187
|
+
*
|
|
188
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
189
|
+
* returns a copy of `this` with a new output type.
|
|
190
|
+
*/
|
|
191
|
+
$notNull() {
|
|
192
|
+
return new AggregateFunctionBuilder(this.#props);
|
|
193
|
+
}
|
|
173
194
|
toOperationNode() {
|
|
174
195
|
return this.#props.aggregateFunctionNode;
|
|
175
196
|
}
|
|
@@ -29,7 +29,7 @@ export declare class CaseThenBuilder<DB, TB extends keyof DB, W, O> {
|
|
|
29
29
|
* A `then` call can be followed by {@link Whenable.when}, {@link CaseWhenBuilder.else},
|
|
30
30
|
* {@link CaseWhenBuilder.end} or {@link CaseWhenBuilder.endCase} call.
|
|
31
31
|
*/
|
|
32
|
-
then<E extends Expression<
|
|
32
|
+
then<E extends Expression<unknown>>(expression: E): CaseWhenBuilder<DB, TB, W, O | ExtractTypeFromValueExpression<E>>;
|
|
33
33
|
then<V>(value: V): CaseWhenBuilder<DB, TB, W, O | V>;
|
|
34
34
|
}
|
|
35
35
|
export declare class CaseWhenBuilder<DB, TB extends keyof DB, W, O> implements Whenable<DB, TB, W, O>, Endable<DB, TB, O | null> {
|
|
@@ -48,7 +48,7 @@ export declare class CaseWhenBuilder<DB, TB extends keyof DB, W, O> implements W
|
|
|
48
48
|
*
|
|
49
49
|
* An `else` call must be followed by an {@link Endable.end} or {@link Endable.endCase} call.
|
|
50
50
|
*/
|
|
51
|
-
else<
|
|
51
|
+
else<E extends Expression<unknown>>(expression: E): CaseEndBuilder<DB, TB, O | ExtractTypeFromValueExpression<E>>;
|
|
52
52
|
else<V>(value: V): CaseEndBuilder<DB, TB, O | V>;
|
|
53
53
|
/**
|
|
54
54
|
* Adds an `end` keyword to the case operator.
|
|
@@ -23,6 +23,7 @@ import { ComparisonOperatorExpression, OperandValueExpressionOrList } from '../p
|
|
|
23
23
|
import { KyselyTypeError } from '../util/type-error.js';
|
|
24
24
|
import { Streamable } from '../util/streamable.js';
|
|
25
25
|
import { ExpressionOrFactory } from '../parser/expression-parser.js';
|
|
26
|
+
import { ValueExpression } from '../parser/value-parser.js';
|
|
26
27
|
export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements WhereInterface<DB, TB>, ReturningInterface<DB, TB, O>, OperationNodeSource, Compilable<O>, Explainable, Streamable<O> {
|
|
27
28
|
#private;
|
|
28
29
|
constructor(props: DeleteQueryBuilderProps);
|
|
@@ -814,7 +815,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
814
815
|
* .execute()
|
|
815
816
|
* ```
|
|
816
817
|
*/
|
|
817
|
-
limit(limit: number): DeleteQueryBuilder<DB, TB, O>;
|
|
818
|
+
limit(limit: ValueExpression<DB, TB, number>): DeleteQueryBuilder<DB, TB, O>;
|
|
818
819
|
/**
|
|
819
820
|
* Simply calls the provided function passing `this` as the only argument. `$call` returns
|
|
820
821
|
* what the provided function returns.
|
|
@@ -877,10 +878,10 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
877
878
|
/**
|
|
878
879
|
* Change the output type of the query.
|
|
879
880
|
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
881
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
882
|
+
* returns a copy of this `DeleteQueryBuilder` with a new output type.
|
|
882
883
|
*/
|
|
883
|
-
$castTo<
|
|
884
|
+
$castTo<C>(): DeleteQueryBuilder<DB, TB, C>;
|
|
884
885
|
/**
|
|
885
886
|
* Narrows (parts of) the output type of the query.
|
|
886
887
|
*
|
|
@@ -11,6 +11,7 @@ import { DeleteQueryNode } from '../operation-node/delete-query-node.js';
|
|
|
11
11
|
import { LimitNode } from '../operation-node/limit-node.js';
|
|
12
12
|
import { parseOrderBy, } from '../parser/order-by-parser.js';
|
|
13
13
|
import { parseValueBinaryOperationOrExpression, parseReferentialBinaryOperation, } from '../parser/binary-operation-parser.js';
|
|
14
|
+
import { parseValueExpression, } from '../parser/value-parser.js';
|
|
14
15
|
export class DeleteQueryBuilder {
|
|
15
16
|
#props;
|
|
16
17
|
constructor(props) {
|
|
@@ -137,7 +138,7 @@ export class DeleteQueryBuilder {
|
|
|
137
138
|
limit(limit) {
|
|
138
139
|
return new DeleteQueryBuilder({
|
|
139
140
|
...this.#props,
|
|
140
|
-
queryNode: DeleteQueryNode.cloneWithLimit(this.#props.queryNode, LimitNode.create(limit)),
|
|
141
|
+
queryNode: DeleteQueryNode.cloneWithLimit(this.#props.queryNode, LimitNode.create(parseValueExpression(limit))),
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
144
|
/**
|
|
@@ -211,8 +212,8 @@ export class DeleteQueryBuilder {
|
|
|
211
212
|
/**
|
|
212
213
|
* Change the output type of the query.
|
|
213
214
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
215
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
216
|
+
* returns a copy of this `DeleteQueryBuilder` with a new output type.
|
|
216
217
|
*/
|
|
217
218
|
$castTo() {
|
|
218
219
|
return new DeleteQueryBuilder(this.#props);
|
|
@@ -138,7 +138,7 @@ export interface FunctionModule<DB, TB extends keyof DB> {
|
|
|
138
138
|
* from "person"
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
|
-
agg<O, RE extends ReferenceExpression<DB, TB>>(name: string, args?: ReadonlyArray<RE>): AggregateFunctionBuilder<DB, TB, O>;
|
|
141
|
+
agg<O, RE extends ReferenceExpression<DB, TB> = ReferenceExpression<DB, TB>>(name: string, args?: ReadonlyArray<RE>): AggregateFunctionBuilder<DB, TB, O>;
|
|
142
142
|
/**
|
|
143
143
|
* Calls the `avg` function for the column or expression given as the argument.
|
|
144
144
|
*
|
|
@@ -240,6 +240,10 @@ export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements R
|
|
|
240
240
|
* ```
|
|
241
241
|
*/
|
|
242
242
|
expression(expression: ExpressionOrFactory<DB, TB, any>): InsertQueryBuilder<DB, TB, O>;
|
|
243
|
+
/**
|
|
244
|
+
* Creates an `insert into "person" default values` query.
|
|
245
|
+
*/
|
|
246
|
+
defaultValues(): InsertQueryBuilder<DB, TB, O>;
|
|
243
247
|
/**
|
|
244
248
|
* Changes an `insert into` query to an `insert ignore into` query.
|
|
245
249
|
*
|
|
@@ -563,10 +567,10 @@ export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements R
|
|
|
563
567
|
/**
|
|
564
568
|
* Change the output type of the query.
|
|
565
569
|
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
570
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
571
|
+
* returns a copy of this `InsertQueryBuilder` with a new output type.
|
|
568
572
|
*/
|
|
569
|
-
$castTo<
|
|
573
|
+
$castTo<C>(): InsertQueryBuilder<DB, TB, C>;
|
|
570
574
|
/**
|
|
571
575
|
* Narrows (parts of) the output type of the query.
|
|
572
576
|
*
|
|
@@ -96,6 +96,17 @@ export class InsertQueryBuilder {
|
|
|
96
96
|
}),
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Creates an `insert into "person" default values` query.
|
|
101
|
+
*/
|
|
102
|
+
defaultValues() {
|
|
103
|
+
return new InsertQueryBuilder({
|
|
104
|
+
...this.#props,
|
|
105
|
+
queryNode: InsertQueryNode.cloneWith(this.#props.queryNode, {
|
|
106
|
+
defaultValues: true,
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
99
110
|
/**
|
|
100
111
|
* Changes an `insert into` query to an `insert ignore into` query.
|
|
101
112
|
*
|
|
@@ -396,8 +407,8 @@ export class InsertQueryBuilder {
|
|
|
396
407
|
/**
|
|
397
408
|
* Change the output type of the query.
|
|
398
409
|
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
410
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
411
|
+
* returns a copy of this `InsertQueryBuilder` with a new output type.
|
|
401
412
|
*/
|
|
402
413
|
$castTo() {
|
|
403
414
|
return new InsertQueryBuilder(this.#props);
|
|
@@ -232,7 +232,8 @@ export declare class TraversedJSONPathBuilder<S, O> extends JSONPathBuilder<S, O
|
|
|
232
232
|
* This method call doesn't change the SQL in any way. This methods simply
|
|
233
233
|
* returns a copy of this `JSONPathBuilder` with a new output type.
|
|
234
234
|
*/
|
|
235
|
-
$castTo<
|
|
235
|
+
$castTo<C>(): JSONPathBuilder<C>;
|
|
236
|
+
$notNull(): JSONPathBuilder<Exclude<O, null>>;
|
|
236
237
|
/**
|
|
237
238
|
* Creates the OperationNode that describes how to compile this expression into SQL.
|
|
238
239
|
*
|
|
@@ -25,6 +25,7 @@ import { Streamable } from '../util/streamable.js';
|
|
|
25
25
|
import { ExpressionOrFactory } from '../parser/expression-parser.js';
|
|
26
26
|
import { ExpressionWrapper } from '../expression/expression-wrapper.js';
|
|
27
27
|
import { SelectQueryBuilderExpression } from './select-query-builder-expression.js';
|
|
28
|
+
import { ValueExpression } from '../parser/value-parser.js';
|
|
28
29
|
export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInterface<DB, TB>, HavingInterface<DB, TB>, SelectQueryBuilderExpression<O>, Compilable<O>, Explainable, Streamable<O> {
|
|
29
30
|
/**
|
|
30
31
|
* Adds a `where` expression to the query.
|
|
@@ -674,19 +675,19 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
|
|
|
674
675
|
/**
|
|
675
676
|
* Adds the `for update` modifier to a select query on supported databases.
|
|
676
677
|
*/
|
|
677
|
-
forUpdate(): SelectQueryBuilder<DB, TB, O>;
|
|
678
|
+
forUpdate(of?: TableOrList<TB>): SelectQueryBuilder<DB, TB, O>;
|
|
678
679
|
/**
|
|
679
680
|
* Adds the `for share` modifier to a select query on supported databases.
|
|
680
681
|
*/
|
|
681
|
-
forShare(): SelectQueryBuilder<DB, TB, O>;
|
|
682
|
+
forShare(of?: TableOrList<TB>): SelectQueryBuilder<DB, TB, O>;
|
|
682
683
|
/**
|
|
683
684
|
* Adds the `for key share` modifier to a select query on supported databases.
|
|
684
685
|
*/
|
|
685
|
-
forKeyShare(): SelectQueryBuilder<DB, TB, O>;
|
|
686
|
+
forKeyShare(of?: TableOrList<TB>): SelectQueryBuilder<DB, TB, O>;
|
|
686
687
|
/**
|
|
687
688
|
* Adds the `for no key update` modifier to a select query on supported databases.
|
|
688
689
|
*/
|
|
689
|
-
forNoKeyUpdate(): SelectQueryBuilder<DB, TB, O>;
|
|
690
|
+
forNoKeyUpdate(of?: TableOrList<TB>): SelectQueryBuilder<DB, TB, O>;
|
|
690
691
|
/**
|
|
691
692
|
* Adds the `skip locked` modifier to a select query on supported databases.
|
|
692
693
|
*/
|
|
@@ -1161,7 +1162,7 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
|
|
|
1161
1162
|
* .limit(10)
|
|
1162
1163
|
* ```
|
|
1163
1164
|
*/
|
|
1164
|
-
limit(limit: number): SelectQueryBuilder<DB, TB, O>;
|
|
1165
|
+
limit(limit: ValueExpression<DB, TB, number>): SelectQueryBuilder<DB, TB, O>;
|
|
1165
1166
|
/**
|
|
1166
1167
|
* Adds an offset clause to the query.
|
|
1167
1168
|
*
|
|
@@ -1177,7 +1178,7 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
|
|
|
1177
1178
|
* .limit(10)
|
|
1178
1179
|
* ```
|
|
1179
1180
|
*/
|
|
1180
|
-
offset(offset: number): SelectQueryBuilder<DB, TB, O>;
|
|
1181
|
+
offset(offset: ValueExpression<DB, TB, number>): SelectQueryBuilder<DB, TB, O>;
|
|
1181
1182
|
/**
|
|
1182
1183
|
* Combines another select query or raw expression to this query using `union`.
|
|
1183
1184
|
*
|
|
@@ -1549,10 +1550,10 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
|
|
|
1549
1550
|
/**
|
|
1550
1551
|
* Change the output type of the query.
|
|
1551
1552
|
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1553
|
+
* This method call doesn't change the SQL in any way. This methods simply
|
|
1554
|
+
* returns a copy of this `SelectQueryBuilder` with a new output type.
|
|
1554
1555
|
*/
|
|
1555
|
-
$castTo<
|
|
1556
|
+
$castTo<C>(): SelectQueryBuilder<DB, TB, C>;
|
|
1556
1557
|
/**
|
|
1557
1558
|
* Changes the output type from an object to a tuple.
|
|
1558
1559
|
*
|
|
@@ -1831,4 +1832,5 @@ type OuterJoinedBuilder<DB, TB extends keyof DB, O, A extends keyof any, R> = Se
|
|
|
1831
1832
|
type OuterJoinedBuilderDB<DB, TB extends keyof DB, A extends keyof any, R> = DrainOuterGeneric<{
|
|
1832
1833
|
[C in keyof DB | A]: C extends A ? Nullable<R> : C extends TB ? Nullable<DB[C]> : C extends keyof DB ? DB[C] : never;
|
|
1833
1834
|
}>;
|
|
1835
|
+
type TableOrList<TB extends keyof any> = (TB & string) | ReadonlyArray<TB & string>;
|
|
1834
1836
|
export {};
|