kysely 0.28.13 → 0.28.15
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-query-compiler.d.ts +8 -0
- package/dist/cjs/dialect/mysql/mysql-query-compiler.js +13 -2
- package/dist/cjs/dialect/postgres/postgres-introspector.js +21 -19
- package/dist/cjs/migration/file-migration-provider.js +34 -1
- package/dist/cjs/query-builder/case-builder.d.ts +16 -0
- package/dist/cjs/query-builder/delete-query-builder.js +24 -22
- package/dist/cjs/query-builder/select-query-builder.js +43 -41
- package/dist/cjs/query-builder/update-query-builder.js +24 -22
- package/dist/cjs/util/column-type.d.ts +54 -0
- package/dist/cjs/util/type-utils.d.ts +1 -1
- package/dist/esm/dialect/mysql/mysql-query-compiler.d.ts +8 -0
- package/dist/esm/dialect/mysql/mysql-query-compiler.js +13 -2
- package/dist/esm/dialect/postgres/postgres-introspector.js +21 -19
- package/dist/esm/query-builder/case-builder.d.ts +16 -0
- package/dist/esm/query-builder/delete-query-builder.js +24 -22
- package/dist/esm/query-builder/select-query-builder.js +43 -41
- package/dist/esm/query-builder/update-query-builder.js +24 -22
- package/dist/esm/util/column-type.d.ts +54 -0
- package/dist/esm/util/type-utils.d.ts +1 -1
- package/package.json +10 -9
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="./select-query-builder.d.ts" />
|
|
2
|
+
var _a;
|
|
2
3
|
import { AliasNode } from '../operation-node/alias-node.js';
|
|
3
4
|
import { SelectModifierNode } from '../operation-node/select-modifier-node.js';
|
|
4
5
|
import { parseJoin, } from '../parser/join-parser.js';
|
|
@@ -32,97 +33,97 @@ class SelectQueryBuilderImpl {
|
|
|
32
33
|
return true;
|
|
33
34
|
}
|
|
34
35
|
where(...args) {
|
|
35
|
-
return new
|
|
36
|
+
return new _a({
|
|
36
37
|
...this.#props,
|
|
37
38
|
queryNode: QueryNode.cloneWithWhere(this.#props.queryNode, parseValueBinaryOperationOrExpression(args)),
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
whereRef(lhs, op, rhs) {
|
|
41
|
-
return new
|
|
42
|
+
return new _a({
|
|
42
43
|
...this.#props,
|
|
43
44
|
queryNode: QueryNode.cloneWithWhere(this.#props.queryNode, parseReferentialBinaryOperation(lhs, op, rhs)),
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
having(...args) {
|
|
47
|
-
return new
|
|
48
|
+
return new _a({
|
|
48
49
|
...this.#props,
|
|
49
50
|
queryNode: SelectQueryNode.cloneWithHaving(this.#props.queryNode, parseValueBinaryOperationOrExpression(args)),
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
havingRef(lhs, op, rhs) {
|
|
53
|
-
return new
|
|
54
|
+
return new _a({
|
|
54
55
|
...this.#props,
|
|
55
56
|
queryNode: SelectQueryNode.cloneWithHaving(this.#props.queryNode, parseReferentialBinaryOperation(lhs, op, rhs)),
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
select(selection) {
|
|
59
|
-
return new
|
|
60
|
+
return new _a({
|
|
60
61
|
...this.#props,
|
|
61
62
|
queryNode: SelectQueryNode.cloneWithSelections(this.#props.queryNode, parseSelectArg(selection)),
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
distinctOn(selection) {
|
|
65
|
-
return new
|
|
66
|
+
return new _a({
|
|
66
67
|
...this.#props,
|
|
67
68
|
queryNode: SelectQueryNode.cloneWithDistinctOn(this.#props.queryNode, parseReferenceExpressionOrList(selection)),
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
modifyFront(modifier) {
|
|
71
|
-
return new
|
|
72
|
+
return new _a({
|
|
72
73
|
...this.#props,
|
|
73
74
|
queryNode: SelectQueryNode.cloneWithFrontModifier(this.#props.queryNode, SelectModifierNode.createWithExpression(modifier.toOperationNode())),
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
modifyEnd(modifier) {
|
|
77
|
-
return new
|
|
78
|
+
return new _a({
|
|
78
79
|
...this.#props,
|
|
79
80
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.createWithExpression(modifier.toOperationNode())),
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
distinct() {
|
|
83
|
-
return new
|
|
84
|
+
return new _a({
|
|
84
85
|
...this.#props,
|
|
85
86
|
queryNode: SelectQueryNode.cloneWithFrontModifier(this.#props.queryNode, SelectModifierNode.create('Distinct')),
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
forUpdate(of) {
|
|
89
|
-
return new
|
|
90
|
+
return new _a({
|
|
90
91
|
...this.#props,
|
|
91
92
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForUpdate', of ? asArray(of).map(parseTable) : undefined)),
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
forShare(of) {
|
|
95
|
-
return new
|
|
96
|
+
return new _a({
|
|
96
97
|
...this.#props,
|
|
97
98
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForShare', of ? asArray(of).map(parseTable) : undefined)),
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
forKeyShare(of) {
|
|
101
|
-
return new
|
|
102
|
+
return new _a({
|
|
102
103
|
...this.#props,
|
|
103
104
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForKeyShare', of ? asArray(of).map(parseTable) : undefined)),
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
forNoKeyUpdate(of) {
|
|
107
|
-
return new
|
|
108
|
+
return new _a({
|
|
108
109
|
...this.#props,
|
|
109
110
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('ForNoKeyUpdate', of ? asArray(of).map(parseTable) : undefined)),
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
skipLocked() {
|
|
113
|
-
return new
|
|
114
|
+
return new _a({
|
|
114
115
|
...this.#props,
|
|
115
116
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('SkipLocked')),
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
119
|
noWait() {
|
|
119
|
-
return new
|
|
120
|
+
return new _a({
|
|
120
121
|
...this.#props,
|
|
121
122
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, SelectModifierNode.create('NoWait')),
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
125
|
selectAll(table) {
|
|
125
|
-
return new
|
|
126
|
+
return new _a({
|
|
126
127
|
...this.#props,
|
|
127
128
|
queryNode: SelectQueryNode.cloneWithSelections(this.#props.queryNode, parseSelectAll(table)),
|
|
128
129
|
});
|
|
@@ -158,79 +159,79 @@ class SelectQueryBuilderImpl {
|
|
|
158
159
|
return this.#join('OuterApply', args);
|
|
159
160
|
}
|
|
160
161
|
#join(joinType, args) {
|
|
161
|
-
return new
|
|
162
|
+
return new _a({
|
|
162
163
|
...this.#props,
|
|
163
164
|
queryNode: QueryNode.cloneWithJoin(this.#props.queryNode, parseJoin(joinType, args)),
|
|
164
165
|
});
|
|
165
166
|
}
|
|
166
167
|
orderBy(...args) {
|
|
167
|
-
return new
|
|
168
|
+
return new _a({
|
|
168
169
|
...this.#props,
|
|
169
170
|
queryNode: QueryNode.cloneWithOrderByItems(this.#props.queryNode, parseOrderBy(args)),
|
|
170
171
|
});
|
|
171
172
|
}
|
|
172
173
|
groupBy(groupBy) {
|
|
173
|
-
return new
|
|
174
|
+
return new _a({
|
|
174
175
|
...this.#props,
|
|
175
176
|
queryNode: SelectQueryNode.cloneWithGroupByItems(this.#props.queryNode, parseGroupBy(groupBy)),
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
179
|
limit(limit) {
|
|
179
|
-
return new
|
|
180
|
+
return new _a({
|
|
180
181
|
...this.#props,
|
|
181
182
|
queryNode: SelectQueryNode.cloneWithLimit(this.#props.queryNode, LimitNode.create(parseValueExpression(limit))),
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
185
|
offset(offset) {
|
|
185
|
-
return new
|
|
186
|
+
return new _a({
|
|
186
187
|
...this.#props,
|
|
187
188
|
queryNode: SelectQueryNode.cloneWithOffset(this.#props.queryNode, OffsetNode.create(parseValueExpression(offset))),
|
|
188
189
|
});
|
|
189
190
|
}
|
|
190
191
|
fetch(rowCount, modifier = 'only') {
|
|
191
|
-
return new
|
|
192
|
+
return new _a({
|
|
192
193
|
...this.#props,
|
|
193
194
|
queryNode: SelectQueryNode.cloneWithFetch(this.#props.queryNode, parseFetch(rowCount, modifier)),
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
197
|
top(expression, modifiers) {
|
|
197
|
-
return new
|
|
198
|
+
return new _a({
|
|
198
199
|
...this.#props,
|
|
199
200
|
queryNode: QueryNode.cloneWithTop(this.#props.queryNode, parseTop(expression, modifiers)),
|
|
200
201
|
});
|
|
201
202
|
}
|
|
202
203
|
union(expression) {
|
|
203
|
-
return new
|
|
204
|
+
return new _a({
|
|
204
205
|
...this.#props,
|
|
205
206
|
queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('union', expression, false)),
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
209
|
unionAll(expression) {
|
|
209
|
-
return new
|
|
210
|
+
return new _a({
|
|
210
211
|
...this.#props,
|
|
211
212
|
queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('union', expression, true)),
|
|
212
213
|
});
|
|
213
214
|
}
|
|
214
215
|
intersect(expression) {
|
|
215
|
-
return new
|
|
216
|
+
return new _a({
|
|
216
217
|
...this.#props,
|
|
217
218
|
queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('intersect', expression, false)),
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
intersectAll(expression) {
|
|
221
|
-
return new
|
|
222
|
+
return new _a({
|
|
222
223
|
...this.#props,
|
|
223
224
|
queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('intersect', expression, true)),
|
|
224
225
|
});
|
|
225
226
|
}
|
|
226
227
|
except(expression) {
|
|
227
|
-
return new
|
|
228
|
+
return new _a({
|
|
228
229
|
...this.#props,
|
|
229
230
|
queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('except', expression, false)),
|
|
230
231
|
});
|
|
231
232
|
}
|
|
232
233
|
exceptAll(expression) {
|
|
233
|
-
return new
|
|
234
|
+
return new _a({
|
|
234
235
|
...this.#props,
|
|
235
236
|
queryNode: SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, parseSetOperations('except', expression, true)),
|
|
236
237
|
});
|
|
@@ -239,37 +240,37 @@ class SelectQueryBuilderImpl {
|
|
|
239
240
|
return new AliasedSelectQueryBuilderImpl(this, alias);
|
|
240
241
|
}
|
|
241
242
|
clearSelect() {
|
|
242
|
-
return new
|
|
243
|
+
return new _a({
|
|
243
244
|
...this.#props,
|
|
244
245
|
queryNode: SelectQueryNode.cloneWithoutSelections(this.#props.queryNode),
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
248
|
clearWhere() {
|
|
248
|
-
return new
|
|
249
|
+
return new _a({
|
|
249
250
|
...this.#props,
|
|
250
251
|
queryNode: QueryNode.cloneWithoutWhere(this.#props.queryNode),
|
|
251
252
|
});
|
|
252
253
|
}
|
|
253
254
|
clearLimit() {
|
|
254
|
-
return new
|
|
255
|
+
return new _a({
|
|
255
256
|
...this.#props,
|
|
256
257
|
queryNode: SelectQueryNode.cloneWithoutLimit(this.#props.queryNode),
|
|
257
258
|
});
|
|
258
259
|
}
|
|
259
260
|
clearOffset() {
|
|
260
|
-
return new
|
|
261
|
+
return new _a({
|
|
261
262
|
...this.#props,
|
|
262
263
|
queryNode: SelectQueryNode.cloneWithoutOffset(this.#props.queryNode),
|
|
263
264
|
});
|
|
264
265
|
}
|
|
265
266
|
clearOrderBy() {
|
|
266
|
-
return new
|
|
267
|
+
return new _a({
|
|
267
268
|
...this.#props,
|
|
268
269
|
queryNode: QueryNode.cloneWithoutOrderBy(this.#props.queryNode),
|
|
269
270
|
});
|
|
270
271
|
}
|
|
271
272
|
clearGroupBy() {
|
|
272
|
-
return new
|
|
273
|
+
return new _a({
|
|
273
274
|
...this.#props,
|
|
274
275
|
queryNode: SelectQueryNode.cloneWithoutGroupBy(this.#props.queryNode),
|
|
275
276
|
});
|
|
@@ -281,18 +282,18 @@ class SelectQueryBuilderImpl {
|
|
|
281
282
|
if (condition) {
|
|
282
283
|
return func(this);
|
|
283
284
|
}
|
|
284
|
-
return new
|
|
285
|
+
return new _a({
|
|
285
286
|
...this.#props,
|
|
286
287
|
});
|
|
287
288
|
}
|
|
288
289
|
$castTo() {
|
|
289
|
-
return new
|
|
290
|
+
return new _a(this.#props);
|
|
290
291
|
}
|
|
291
292
|
$narrowType() {
|
|
292
|
-
return new
|
|
293
|
+
return new _a(this.#props);
|
|
293
294
|
}
|
|
294
295
|
$assertType() {
|
|
295
|
-
return new
|
|
296
|
+
return new _a(this.#props);
|
|
296
297
|
}
|
|
297
298
|
$asTuple() {
|
|
298
299
|
return new ExpressionWrapper(this.toOperationNode());
|
|
@@ -301,7 +302,7 @@ class SelectQueryBuilderImpl {
|
|
|
301
302
|
return new ExpressionWrapper(this.toOperationNode());
|
|
302
303
|
}
|
|
303
304
|
withPlugin(plugin) {
|
|
304
|
-
return new
|
|
305
|
+
return new _a({
|
|
305
306
|
...this.#props,
|
|
306
307
|
executor: this.#props.executor.withPlugin(plugin),
|
|
307
308
|
});
|
|
@@ -339,13 +340,14 @@ class SelectQueryBuilderImpl {
|
|
|
339
340
|
}
|
|
340
341
|
}
|
|
341
342
|
async explain(format, options) {
|
|
342
|
-
const builder = new
|
|
343
|
+
const builder = new _a({
|
|
343
344
|
...this.#props,
|
|
344
345
|
queryNode: QueryNode.cloneWithExplain(this.#props.queryNode, format, options),
|
|
345
346
|
});
|
|
346
347
|
return await builder.execute();
|
|
347
348
|
}
|
|
348
349
|
}
|
|
350
|
+
_a = SelectQueryBuilderImpl;
|
|
349
351
|
export function createSelectQueryBuilder(props) {
|
|
350
352
|
return new SelectQueryBuilderImpl(props);
|
|
351
353
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="./update-query-builder.d.ts" />
|
|
2
|
+
var _a;
|
|
2
3
|
import { parseJoin, } from '../parser/join-parser.js';
|
|
3
4
|
import { parseTableExpressionOrList, } from '../parser/table-parser.js';
|
|
4
5
|
import { parseSelectArg, parseSelectAll, } from '../parser/select-parser.js';
|
|
@@ -19,19 +20,19 @@ export class UpdateQueryBuilder {
|
|
|
19
20
|
this.#props = freeze(props);
|
|
20
21
|
}
|
|
21
22
|
where(...args) {
|
|
22
|
-
return new
|
|
23
|
+
return new _a({
|
|
23
24
|
...this.#props,
|
|
24
25
|
queryNode: QueryNode.cloneWithWhere(this.#props.queryNode, parseValueBinaryOperationOrExpression(args)),
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
whereRef(lhs, op, rhs) {
|
|
28
|
-
return new
|
|
29
|
+
return new _a({
|
|
29
30
|
...this.#props,
|
|
30
31
|
queryNode: QueryNode.cloneWithWhere(this.#props.queryNode, parseReferentialBinaryOperation(lhs, op, rhs)),
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
clearWhere() {
|
|
34
|
-
return new
|
|
35
|
+
return new _a({
|
|
35
36
|
...this.#props,
|
|
36
37
|
queryNode: QueryNode.cloneWithoutWhere(this.#props.queryNode),
|
|
37
38
|
});
|
|
@@ -76,13 +77,13 @@ export class UpdateQueryBuilder {
|
|
|
76
77
|
* ```
|
|
77
78
|
*/
|
|
78
79
|
top(expression, modifiers) {
|
|
79
|
-
return new
|
|
80
|
+
return new _a({
|
|
80
81
|
...this.#props,
|
|
81
82
|
queryNode: QueryNode.cloneWithTop(this.#props.queryNode, parseTop(expression, modifiers)),
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
from(from) {
|
|
85
|
-
return new
|
|
86
|
+
return new _a({
|
|
86
87
|
...this.#props,
|
|
87
88
|
queryNode: UpdateQueryNode.cloneWithFromItems(this.#props.queryNode, parseTableExpressionOrList(from)),
|
|
88
89
|
});
|
|
@@ -100,19 +101,19 @@ export class UpdateQueryBuilder {
|
|
|
100
101
|
return this.#join('FullJoin', args);
|
|
101
102
|
}
|
|
102
103
|
#join(joinType, args) {
|
|
103
|
-
return new
|
|
104
|
+
return new _a({
|
|
104
105
|
...this.#props,
|
|
105
106
|
queryNode: QueryNode.cloneWithJoin(this.#props.queryNode, parseJoin(joinType, args)),
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
orderBy(...args) {
|
|
109
|
-
return new
|
|
110
|
+
return new _a({
|
|
110
111
|
...this.#props,
|
|
111
112
|
queryNode: QueryNode.cloneWithOrderByItems(this.#props.queryNode, parseOrderBy(args)),
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
115
|
clearOrderBy() {
|
|
115
|
-
return new
|
|
116
|
+
return new _a({
|
|
116
117
|
...this.#props,
|
|
117
118
|
queryNode: QueryNode.cloneWithoutOrderBy(this.#props.queryNode),
|
|
118
119
|
});
|
|
@@ -139,37 +140,37 @@ export class UpdateQueryBuilder {
|
|
|
139
140
|
* ```
|
|
140
141
|
*/
|
|
141
142
|
limit(limit) {
|
|
142
|
-
return new
|
|
143
|
+
return new _a({
|
|
143
144
|
...this.#props,
|
|
144
145
|
queryNode: UpdateQueryNode.cloneWithLimit(this.#props.queryNode, LimitNode.create(parseValueExpression(limit))),
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
148
|
set(...args) {
|
|
148
|
-
return new
|
|
149
|
+
return new _a({
|
|
149
150
|
...this.#props,
|
|
150
151
|
queryNode: UpdateQueryNode.cloneWithUpdates(this.#props.queryNode, parseUpdate(...args)),
|
|
151
152
|
});
|
|
152
153
|
}
|
|
153
154
|
returning(selection) {
|
|
154
|
-
return new
|
|
155
|
+
return new _a({
|
|
155
156
|
...this.#props,
|
|
156
157
|
queryNode: QueryNode.cloneWithReturning(this.#props.queryNode, parseSelectArg(selection)),
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
160
|
returningAll(table) {
|
|
160
|
-
return new
|
|
161
|
+
return new _a({
|
|
161
162
|
...this.#props,
|
|
162
163
|
queryNode: QueryNode.cloneWithReturning(this.#props.queryNode, parseSelectAll(table)),
|
|
163
164
|
});
|
|
164
165
|
}
|
|
165
166
|
output(args) {
|
|
166
|
-
return new
|
|
167
|
+
return new _a({
|
|
167
168
|
...this.#props,
|
|
168
169
|
queryNode: QueryNode.cloneWithOutput(this.#props.queryNode, parseSelectArg(args)),
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
outputAll(table) {
|
|
172
|
-
return new
|
|
173
|
+
return new _a({
|
|
173
174
|
...this.#props,
|
|
174
175
|
queryNode: QueryNode.cloneWithOutput(this.#props.queryNode, parseSelectAll(table)),
|
|
175
176
|
});
|
|
@@ -198,7 +199,7 @@ export class UpdateQueryBuilder {
|
|
|
198
199
|
* ```
|
|
199
200
|
*/
|
|
200
201
|
modifyEnd(modifier) {
|
|
201
|
-
return new
|
|
202
|
+
return new _a({
|
|
202
203
|
...this.#props,
|
|
203
204
|
queryNode: QueryNode.cloneWithEndModifier(this.#props.queryNode, modifier.toOperationNode()),
|
|
204
205
|
});
|
|
@@ -223,7 +224,7 @@ export class UpdateQueryBuilder {
|
|
|
223
224
|
* ```
|
|
224
225
|
*/
|
|
225
226
|
clearReturning() {
|
|
226
|
-
return new
|
|
227
|
+
return new _a({
|
|
227
228
|
...this.#props,
|
|
228
229
|
queryNode: QueryNode.cloneWithoutReturning(this.#props.queryNode),
|
|
229
230
|
});
|
|
@@ -303,7 +304,7 @@ export class UpdateQueryBuilder {
|
|
|
303
304
|
if (condition) {
|
|
304
305
|
return func(this);
|
|
305
306
|
}
|
|
306
|
-
return new
|
|
307
|
+
return new _a({
|
|
307
308
|
...this.#props,
|
|
308
309
|
});
|
|
309
310
|
}
|
|
@@ -314,7 +315,7 @@ export class UpdateQueryBuilder {
|
|
|
314
315
|
* returns a copy of this `UpdateQueryBuilder` with a new output type.
|
|
315
316
|
*/
|
|
316
317
|
$castTo() {
|
|
317
|
-
return new
|
|
318
|
+
return new _a(this.#props);
|
|
318
319
|
}
|
|
319
320
|
/**
|
|
320
321
|
* Narrows (parts of) the output type of the query.
|
|
@@ -375,7 +376,7 @@ export class UpdateQueryBuilder {
|
|
|
375
376
|
* ```
|
|
376
377
|
*/
|
|
377
378
|
$narrowType() {
|
|
378
|
-
return new
|
|
379
|
+
return new _a(this.#props);
|
|
379
380
|
}
|
|
380
381
|
/**
|
|
381
382
|
* Asserts that query's output row type equals the given type `T`.
|
|
@@ -432,13 +433,13 @@ export class UpdateQueryBuilder {
|
|
|
432
433
|
* ```
|
|
433
434
|
*/
|
|
434
435
|
$assertType() {
|
|
435
|
-
return new
|
|
436
|
+
return new _a(this.#props);
|
|
436
437
|
}
|
|
437
438
|
/**
|
|
438
439
|
* Returns a copy of this UpdateQueryBuilder instance with the given plugin installed.
|
|
439
440
|
*/
|
|
440
441
|
withPlugin(plugin) {
|
|
441
|
-
return new
|
|
442
|
+
return new _a({
|
|
442
443
|
...this.#props,
|
|
443
444
|
executor: this.#props.executor.withPlugin(plugin),
|
|
444
445
|
});
|
|
@@ -501,10 +502,11 @@ export class UpdateQueryBuilder {
|
|
|
501
502
|
}
|
|
502
503
|
}
|
|
503
504
|
async explain(format, options) {
|
|
504
|
-
const builder = new
|
|
505
|
+
const builder = new _a({
|
|
505
506
|
...this.#props,
|
|
506
507
|
queryNode: QueryNode.cloneWithExplain(this.#props.queryNode, format, options),
|
|
507
508
|
});
|
|
508
509
|
return await builder.execute();
|
|
509
510
|
}
|
|
510
511
|
}
|
|
512
|
+
_a = UpdateQueryBuilder;
|
|
@@ -172,4 +172,58 @@ export type Insertable<R> = DrainOuterGeneric<object & {
|
|
|
172
172
|
export type Updateable<R> = DrainOuterGeneric<{
|
|
173
173
|
[K in UpdateKeys<R>]?: UpdateType<R[K]>;
|
|
174
174
|
}>;
|
|
175
|
+
/**
|
|
176
|
+
* Wrap your column type to opt-out from dehydration by {@link ShallowDehydrateValue},
|
|
177
|
+
* when used by JSON functions, such as the ones used by the relational helpers.
|
|
178
|
+
*
|
|
179
|
+
* Why need this?
|
|
180
|
+
*
|
|
181
|
+
* An edge case surfaced in issues where a numeric string column type was actually
|
|
182
|
+
* not a numeric data type column, but text - and thus shouldn't be dehydrated
|
|
183
|
+
* to `number`.
|
|
184
|
+
*
|
|
185
|
+
* Another use case would be, when someone finds a way to keep nested columns hydrated
|
|
186
|
+
* at runtime, e.g. via a plugin, and wants to prevent dehydration of such columns
|
|
187
|
+
* at the type level.
|
|
188
|
+
*
|
|
189
|
+
* ### Examples
|
|
190
|
+
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* import type { NonDehydrateable } from 'kysely'
|
|
193
|
+
* import { jsonArrayFrom } from 'kysely/helpers/postgres'
|
|
194
|
+
*
|
|
195
|
+
* const result = await db
|
|
196
|
+
* .withTables<{
|
|
197
|
+
* my_table: {
|
|
198
|
+
* a_column: '1' | '2' | '3',
|
|
199
|
+
* another_column: NonDehydrateable<'1' | '2' | '3'>,
|
|
200
|
+
* column_too: NonDehydrateable<ColumnType<'1' | '2' | '3'>>
|
|
201
|
+
* }
|
|
202
|
+
* }>()
|
|
203
|
+
* .selectFrom('person')
|
|
204
|
+
* .select((eb) => [
|
|
205
|
+
* 'id',
|
|
206
|
+
* jsonArrayFrom(
|
|
207
|
+
* eb.selectFrom('my_table')
|
|
208
|
+
* .select(['a_column', 'another_column', 'column_too'])
|
|
209
|
+
* ).as('related')
|
|
210
|
+
* ])
|
|
211
|
+
* .execute()
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* In the example above, "a_column" will be dehydrated to `number`
|
|
215
|
+
* given it is a numeric string - which is normally a numeric data type column
|
|
216
|
+
* that gets output as a string by underlying database drivers to avoid
|
|
217
|
+
* precision loss or overflow.
|
|
218
|
+
*
|
|
219
|
+
* "another_column" and "column_too" will remain as `'1' | '2' | '3'`, given they're
|
|
220
|
+
* wrapped in `NonDehydrateable`, which prevents their dehydration.
|
|
221
|
+
*/
|
|
222
|
+
export type NonDehydrateable<T> = [T] extends [
|
|
223
|
+
ColumnType<infer S, infer I, infer U>
|
|
224
|
+
] ? ColumnType<S & {
|
|
225
|
+
__kysely_dehydrate__?: false;
|
|
226
|
+
}, I, U> : T & {
|
|
227
|
+
__kysely_dehydrate__?: false;
|
|
228
|
+
};
|
|
175
229
|
export {};
|
|
@@ -183,7 +183,7 @@ export type ShallowDehydrateObject<O> = {
|
|
|
183
183
|
* For now, we catch anything in {@link StringsWhenDataTypeNotAvailable} and convert it to `string`,
|
|
184
184
|
* and anything in {@link NumbersWhenDataTypeNotAvailable} and convert it to `number`.
|
|
185
185
|
*/
|
|
186
|
-
export type ShallowDehydrateValue<T> = T extends null | undefined ? T : T extends (infer U)[] | null | undefined ? Array<ShallowDehydrateValue<U>> | Extract<T, null | undefined> : Exclude<T, StringsWhenDataTypeNotAvailable | NumbersWhenDataTypeNotAvailable> | ([Extract<T, NumbersWhenDataTypeNotAvailable>] extends [never] ? never : number) | ([Extract<T, StringsWhenDataTypeNotAvailable>] extends [never] ? never : string);
|
|
186
|
+
export type ShallowDehydrateValue<T> = T extends null | undefined ? T : '__kysely_dehydrate__' extends keyof NonNullable<T> ? T : T extends (infer U)[] | null | undefined ? Array<ShallowDehydrateValue<U>> | Extract<T, null | undefined> : Exclude<T, StringsWhenDataTypeNotAvailable | NumbersWhenDataTypeNotAvailable> | ([Extract<T, NumbersWhenDataTypeNotAvailable>] extends [never] ? never : number) | ([Extract<T, StringsWhenDataTypeNotAvailable>] extends [never] ? never : string);
|
|
187
187
|
export type StringsWhenDataTypeNotAvailable = Date | Uint8Array;
|
|
188
188
|
export type NumbersWhenDataTypeNotAvailable = bigint | NumericString;
|
|
189
189
|
export type NumericString = `${number}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kysely",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.15",
|
|
4
4
|
"description": "Type safe SQL query builder",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=20.0.0"
|
|
29
29
|
},
|
|
30
|
+
"type": "module",
|
|
30
31
|
"main": "dist/cjs/index.js",
|
|
31
32
|
"module": "dist/esm/index.js",
|
|
32
33
|
"typesVersions": {
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
"@types/chai-as-promised": "^8.0.2",
|
|
84
85
|
"@types/mocha": "^10.0.10",
|
|
85
86
|
"@types/node": "^25.5.0",
|
|
86
|
-
"@types/pg": "^8.
|
|
87
|
+
"@types/pg": "^8.20.0",
|
|
87
88
|
"@types/pg-cursor": "^2.7.2",
|
|
88
89
|
"@types/semver": "^7.7.1",
|
|
89
90
|
"@types/sinon": "^21.0.0",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"tarn": "^3.0.2",
|
|
108
109
|
"tedious": "^19.2.1",
|
|
109
110
|
"tsd": "^0.33.0",
|
|
110
|
-
"typescript": "~
|
|
111
|
+
"typescript": "~6.0.2"
|
|
111
112
|
},
|
|
112
113
|
"scripts": {
|
|
113
114
|
"clean": "rm -rf dist & rm -rf test/node/dist & rm -rf test/browser/bundle.js & rm -rf helpers",
|
|
@@ -122,9 +123,9 @@
|
|
|
122
123
|
"test:cloudflare-workers": "pnpm build && pnpm -r test --filter kysely-cloudflare-workers-test",
|
|
123
124
|
"test:deno": "deno run --allow-env --allow-read --allow-net --no-lock test/deno/local.test.ts && deno run --allow-env --allow-read --allow-net --no-lock test/deno/cdn.test.ts",
|
|
124
125
|
"test:typings": "tsd test/typings",
|
|
125
|
-
"test:esmimports": "node scripts/check-esm-imports.
|
|
126
|
+
"test:esmimports": "node scripts/check-esm-imports.cjs",
|
|
126
127
|
"test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
|
|
127
|
-
"test:exports": "attw --pack . && node scripts/check-exports.
|
|
128
|
+
"test:exports": "attw --pack . && node scripts/check-exports.cjs",
|
|
128
129
|
"test:jsdocs": "deno check --doc-only --no-lock --unstable-sloppy-imports --config=\"deno.check.json\" ./src",
|
|
129
130
|
"test:outdatedts": "pnpm build && cd test/outdated-ts && pnpm i && pnpm test",
|
|
130
131
|
"lint:deno": "deno lint --config=\"deno.lint.json\" ./src",
|
|
@@ -132,11 +133,11 @@
|
|
|
132
133
|
"build": "pnpm clean && (pnpm build:esm & pnpm build:cjs) && pnpm script:module-fixup && pnpm script:copy-interface-doc",
|
|
133
134
|
"build:esm": "tsc -p tsconfig.json && pnpm script:add-deno-type-references",
|
|
134
135
|
"build:cjs": "tsc -p tsconfig-cjs.json",
|
|
135
|
-
"script:module-fixup": "node scripts/module-fixup.
|
|
136
|
-
"script:copy-interface-doc": "node scripts/copy-interface-documentation.
|
|
137
|
-
"script:add-deno-type-references": "node scripts/add-deno-type-references.
|
|
136
|
+
"script:module-fixup": "node scripts/module-fixup.cjs",
|
|
137
|
+
"script:copy-interface-doc": "node scripts/copy-interface-documentation.cjs",
|
|
138
|
+
"script:add-deno-type-references": "node scripts/add-deno-type-references.cjs",
|
|
138
139
|
"script:align-versions": "node --experimental-strip-types scripts/align-versions.mts",
|
|
139
|
-
"script:generate-site-examples": "node scripts/generate-site-examples.
|
|
140
|
+
"script:generate-site-examples": "node scripts/generate-site-examples.cjs",
|
|
140
141
|
"script:exclude-test-files-for-backwards-compat": "node --experimental-strip-types scripts/exclude-test-files-for-backwards-compat.mts",
|
|
141
142
|
"script:remove-global-augmentations": "node --experimental-strip-types scripts/remove-global-augmentations.mts",
|
|
142
143
|
"version": "pnpm script:align-versions && git add ."
|