kysely 0.28.14 → 0.28.16

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.
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.createSelectQueryBuilder = createSelectQueryBuilder;
4
5
  const alias_node_js_1 = require("../operation-node/alias-node.js");
@@ -34,97 +35,97 @@ class SelectQueryBuilderImpl {
34
35
  return true;
35
36
  }
36
37
  where(...args) {
37
- return new SelectQueryBuilderImpl({
38
+ return new _a({
38
39
  ...this.#props,
39
40
  queryNode: query_node_js_1.QueryNode.cloneWithWhere(this.#props.queryNode, (0, binary_operation_parser_js_1.parseValueBinaryOperationOrExpression)(args)),
40
41
  });
41
42
  }
42
43
  whereRef(lhs, op, rhs) {
43
- return new SelectQueryBuilderImpl({
44
+ return new _a({
44
45
  ...this.#props,
45
46
  queryNode: query_node_js_1.QueryNode.cloneWithWhere(this.#props.queryNode, (0, binary_operation_parser_js_1.parseReferentialBinaryOperation)(lhs, op, rhs)),
46
47
  });
47
48
  }
48
49
  having(...args) {
49
- return new SelectQueryBuilderImpl({
50
+ return new _a({
50
51
  ...this.#props,
51
52
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithHaving(this.#props.queryNode, (0, binary_operation_parser_js_1.parseValueBinaryOperationOrExpression)(args)),
52
53
  });
53
54
  }
54
55
  havingRef(lhs, op, rhs) {
55
- return new SelectQueryBuilderImpl({
56
+ return new _a({
56
57
  ...this.#props,
57
58
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithHaving(this.#props.queryNode, (0, binary_operation_parser_js_1.parseReferentialBinaryOperation)(lhs, op, rhs)),
58
59
  });
59
60
  }
60
61
  select(selection) {
61
- return new SelectQueryBuilderImpl({
62
+ return new _a({
62
63
  ...this.#props,
63
64
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSelections(this.#props.queryNode, (0, select_parser_js_1.parseSelectArg)(selection)),
64
65
  });
65
66
  }
66
67
  distinctOn(selection) {
67
- return new SelectQueryBuilderImpl({
68
+ return new _a({
68
69
  ...this.#props,
69
70
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithDistinctOn(this.#props.queryNode, (0, reference_parser_js_1.parseReferenceExpressionOrList)(selection)),
70
71
  });
71
72
  }
72
73
  modifyFront(modifier) {
73
- return new SelectQueryBuilderImpl({
74
+ return new _a({
74
75
  ...this.#props,
75
76
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithFrontModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.createWithExpression(modifier.toOperationNode())),
76
77
  });
77
78
  }
78
79
  modifyEnd(modifier) {
79
- return new SelectQueryBuilderImpl({
80
+ return new _a({
80
81
  ...this.#props,
81
82
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.createWithExpression(modifier.toOperationNode())),
82
83
  });
83
84
  }
84
85
  distinct() {
85
- return new SelectQueryBuilderImpl({
86
+ return new _a({
86
87
  ...this.#props,
87
88
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithFrontModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.create('Distinct')),
88
89
  });
89
90
  }
90
91
  forUpdate(of) {
91
- return new SelectQueryBuilderImpl({
92
+ return new _a({
92
93
  ...this.#props,
93
94
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.create('ForUpdate', of ? (0, object_utils_js_1.asArray)(of).map(table_parser_js_1.parseTable) : undefined)),
94
95
  });
95
96
  }
96
97
  forShare(of) {
97
- return new SelectQueryBuilderImpl({
98
+ return new _a({
98
99
  ...this.#props,
99
100
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.create('ForShare', of ? (0, object_utils_js_1.asArray)(of).map(table_parser_js_1.parseTable) : undefined)),
100
101
  });
101
102
  }
102
103
  forKeyShare(of) {
103
- return new SelectQueryBuilderImpl({
104
+ return new _a({
104
105
  ...this.#props,
105
106
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.create('ForKeyShare', of ? (0, object_utils_js_1.asArray)(of).map(table_parser_js_1.parseTable) : undefined)),
106
107
  });
107
108
  }
108
109
  forNoKeyUpdate(of) {
109
- return new SelectQueryBuilderImpl({
110
+ return new _a({
110
111
  ...this.#props,
111
112
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.create('ForNoKeyUpdate', of ? (0, object_utils_js_1.asArray)(of).map(table_parser_js_1.parseTable) : undefined)),
112
113
  });
113
114
  }
114
115
  skipLocked() {
115
- return new SelectQueryBuilderImpl({
116
+ return new _a({
116
117
  ...this.#props,
117
118
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.create('SkipLocked')),
118
119
  });
119
120
  }
120
121
  noWait() {
121
- return new SelectQueryBuilderImpl({
122
+ return new _a({
122
123
  ...this.#props,
123
124
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, select_modifier_node_js_1.SelectModifierNode.create('NoWait')),
124
125
  });
125
126
  }
126
127
  selectAll(table) {
127
- return new SelectQueryBuilderImpl({
128
+ return new _a({
128
129
  ...this.#props,
129
130
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSelections(this.#props.queryNode, (0, select_parser_js_1.parseSelectAll)(table)),
130
131
  });
@@ -160,79 +161,79 @@ class SelectQueryBuilderImpl {
160
161
  return this.#join('OuterApply', args);
161
162
  }
162
163
  #join(joinType, args) {
163
- return new SelectQueryBuilderImpl({
164
+ return new _a({
164
165
  ...this.#props,
165
166
  queryNode: query_node_js_1.QueryNode.cloneWithJoin(this.#props.queryNode, (0, join_parser_js_1.parseJoin)(joinType, args)),
166
167
  });
167
168
  }
168
169
  orderBy(...args) {
169
- return new SelectQueryBuilderImpl({
170
+ return new _a({
170
171
  ...this.#props,
171
172
  queryNode: query_node_js_1.QueryNode.cloneWithOrderByItems(this.#props.queryNode, (0, order_by_parser_js_1.parseOrderBy)(args)),
172
173
  });
173
174
  }
174
175
  groupBy(groupBy) {
175
- return new SelectQueryBuilderImpl({
176
+ return new _a({
176
177
  ...this.#props,
177
178
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithGroupByItems(this.#props.queryNode, (0, group_by_parser_js_1.parseGroupBy)(groupBy)),
178
179
  });
179
180
  }
180
181
  limit(limit) {
181
- return new SelectQueryBuilderImpl({
182
+ return new _a({
182
183
  ...this.#props,
183
184
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithLimit(this.#props.queryNode, limit_node_js_1.LimitNode.create((0, value_parser_js_1.parseValueExpression)(limit))),
184
185
  });
185
186
  }
186
187
  offset(offset) {
187
- return new SelectQueryBuilderImpl({
188
+ return new _a({
188
189
  ...this.#props,
189
190
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithOffset(this.#props.queryNode, offset_node_js_1.OffsetNode.create((0, value_parser_js_1.parseValueExpression)(offset))),
190
191
  });
191
192
  }
192
193
  fetch(rowCount, modifier = 'only') {
193
- return new SelectQueryBuilderImpl({
194
+ return new _a({
194
195
  ...this.#props,
195
196
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithFetch(this.#props.queryNode, (0, fetch_parser_js_1.parseFetch)(rowCount, modifier)),
196
197
  });
197
198
  }
198
199
  top(expression, modifiers) {
199
- return new SelectQueryBuilderImpl({
200
+ return new _a({
200
201
  ...this.#props,
201
202
  queryNode: query_node_js_1.QueryNode.cloneWithTop(this.#props.queryNode, (0, top_parser_js_1.parseTop)(expression, modifiers)),
202
203
  });
203
204
  }
204
205
  union(expression) {
205
- return new SelectQueryBuilderImpl({
206
+ return new _a({
206
207
  ...this.#props,
207
208
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, (0, set_operation_parser_js_1.parseSetOperations)('union', expression, false)),
208
209
  });
209
210
  }
210
211
  unionAll(expression) {
211
- return new SelectQueryBuilderImpl({
212
+ return new _a({
212
213
  ...this.#props,
213
214
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, (0, set_operation_parser_js_1.parseSetOperations)('union', expression, true)),
214
215
  });
215
216
  }
216
217
  intersect(expression) {
217
- return new SelectQueryBuilderImpl({
218
+ return new _a({
218
219
  ...this.#props,
219
220
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, (0, set_operation_parser_js_1.parseSetOperations)('intersect', expression, false)),
220
221
  });
221
222
  }
222
223
  intersectAll(expression) {
223
- return new SelectQueryBuilderImpl({
224
+ return new _a({
224
225
  ...this.#props,
225
226
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, (0, set_operation_parser_js_1.parseSetOperations)('intersect', expression, true)),
226
227
  });
227
228
  }
228
229
  except(expression) {
229
- return new SelectQueryBuilderImpl({
230
+ return new _a({
230
231
  ...this.#props,
231
232
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, (0, set_operation_parser_js_1.parseSetOperations)('except', expression, false)),
232
233
  });
233
234
  }
234
235
  exceptAll(expression) {
235
- return new SelectQueryBuilderImpl({
236
+ return new _a({
236
237
  ...this.#props,
237
238
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithSetOperations(this.#props.queryNode, (0, set_operation_parser_js_1.parseSetOperations)('except', expression, true)),
238
239
  });
@@ -241,37 +242,37 @@ class SelectQueryBuilderImpl {
241
242
  return new AliasedSelectQueryBuilderImpl(this, alias);
242
243
  }
243
244
  clearSelect() {
244
- return new SelectQueryBuilderImpl({
245
+ return new _a({
245
246
  ...this.#props,
246
247
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithoutSelections(this.#props.queryNode),
247
248
  });
248
249
  }
249
250
  clearWhere() {
250
- return new SelectQueryBuilderImpl({
251
+ return new _a({
251
252
  ...this.#props,
252
253
  queryNode: query_node_js_1.QueryNode.cloneWithoutWhere(this.#props.queryNode),
253
254
  });
254
255
  }
255
256
  clearLimit() {
256
- return new SelectQueryBuilderImpl({
257
+ return new _a({
257
258
  ...this.#props,
258
259
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithoutLimit(this.#props.queryNode),
259
260
  });
260
261
  }
261
262
  clearOffset() {
262
- return new SelectQueryBuilderImpl({
263
+ return new _a({
263
264
  ...this.#props,
264
265
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithoutOffset(this.#props.queryNode),
265
266
  });
266
267
  }
267
268
  clearOrderBy() {
268
- return new SelectQueryBuilderImpl({
269
+ return new _a({
269
270
  ...this.#props,
270
271
  queryNode: query_node_js_1.QueryNode.cloneWithoutOrderBy(this.#props.queryNode),
271
272
  });
272
273
  }
273
274
  clearGroupBy() {
274
- return new SelectQueryBuilderImpl({
275
+ return new _a({
275
276
  ...this.#props,
276
277
  queryNode: select_query_node_js_1.SelectQueryNode.cloneWithoutGroupBy(this.#props.queryNode),
277
278
  });
@@ -283,18 +284,18 @@ class SelectQueryBuilderImpl {
283
284
  if (condition) {
284
285
  return func(this);
285
286
  }
286
- return new SelectQueryBuilderImpl({
287
+ return new _a({
287
288
  ...this.#props,
288
289
  });
289
290
  }
290
291
  $castTo() {
291
- return new SelectQueryBuilderImpl(this.#props);
292
+ return new _a(this.#props);
292
293
  }
293
294
  $narrowType() {
294
- return new SelectQueryBuilderImpl(this.#props);
295
+ return new _a(this.#props);
295
296
  }
296
297
  $assertType() {
297
- return new SelectQueryBuilderImpl(this.#props);
298
+ return new _a(this.#props);
298
299
  }
299
300
  $asTuple() {
300
301
  return new expression_wrapper_js_1.ExpressionWrapper(this.toOperationNode());
@@ -303,7 +304,7 @@ class SelectQueryBuilderImpl {
303
304
  return new expression_wrapper_js_1.ExpressionWrapper(this.toOperationNode());
304
305
  }
305
306
  withPlugin(plugin) {
306
- return new SelectQueryBuilderImpl({
307
+ return new _a({
307
308
  ...this.#props,
308
309
  executor: this.#props.executor.withPlugin(plugin),
309
310
  });
@@ -341,13 +342,14 @@ class SelectQueryBuilderImpl {
341
342
  }
342
343
  }
343
344
  async explain(format, options) {
344
- const builder = new SelectQueryBuilderImpl({
345
+ const builder = new _a({
345
346
  ...this.#props,
346
347
  queryNode: query_node_js_1.QueryNode.cloneWithExplain(this.#props.queryNode, format, options),
347
348
  });
348
349
  return await builder.execute();
349
350
  }
350
351
  }
352
+ _a = SelectQueryBuilderImpl;
351
353
  function createSelectQueryBuilder(props) {
352
354
  return new SelectQueryBuilderImpl(props);
353
355
  }
@@ -602,21 +602,21 @@ export declare class UpdateQueryBuilder<DB, UT extends keyof DB, TB extends keyo
602
602
  fullJoin<TE extends TableExpression<DB, TB>, K1 extends JoinReferenceExpression<DB, TB, TE>, K2 extends JoinReferenceExpression<DB, TB, TE>>(table: TE, k1: K1, k2: K2): UpdateQueryBuilderWithFullJoin<DB, UT, TB, O, TE>;
603
603
  fullJoin<TE extends TableExpression<DB, TB>, FN extends JoinCallbackExpression<DB, TB, TE>>(table: TE, callback: FN): UpdateQueryBuilderWithFullJoin<DB, UT, TB, O, TE>;
604
604
  /**
605
- * @description This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
605
+ * @remarks This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
606
606
  */
607
607
  orderBy<OE extends OrderByExpression<DB, TB, {}>>(expr: OE, modifiers?: OrderByModifiers): UpdateQueryBuilder<DB, UT, TB, O>;
608
608
  /**
609
- * @description This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
609
+ * @remarks This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
610
610
  * @deprecated It does ~2-2.6x more compile-time instantiations compared to multiple chained `orderBy(expr, modifiers?)` calls (in `order by` clauses with reasonable item counts), and has broken autocompletion.
611
611
  */
612
612
  orderBy<OE extends OrderByExpression<DB, TB, {}> | DirectedOrderByStringReference<DB, TB, {}>>(exprs: ReadonlyArray<OE>): UpdateQueryBuilder<DB, UT, TB, O>;
613
613
  /**
614
- * @description This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
614
+ * @remarks This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
615
615
  * @deprecated It does ~2.9x more compile-time instantiations compared to a `orderBy(expr, direction)` call.
616
616
  */
617
617
  orderBy<OE extends DirectedOrderByStringReference<DB, TB, {}>>(expr: OE): UpdateQueryBuilder<DB, UT, TB, O>;
618
618
  /**
619
- * @description This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
619
+ * @remarks This is only supported by some dialects like MySQL or SQLite with `SQLITE_ENABLE_UPDATE_DELETE_LIMIT`.
620
620
  * @deprecated Use `orderBy(expr, (ob) => ...)` instead.
621
621
  */
622
622
  orderBy<OE extends OrderByExpression<DB, TB, {}>>(expr: OE, modifiers: Expression<any>): UpdateQueryBuilder<DB, UT, TB, O>;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.UpdateQueryBuilder = void 0;
4
5
  const join_parser_js_1 = require("../parser/join-parser.js");
@@ -21,19 +22,19 @@ class UpdateQueryBuilder {
21
22
  this.#props = (0, object_utils_js_1.freeze)(props);
22
23
  }
23
24
  where(...args) {
24
- return new UpdateQueryBuilder({
25
+ return new _a({
25
26
  ...this.#props,
26
27
  queryNode: query_node_js_1.QueryNode.cloneWithWhere(this.#props.queryNode, (0, binary_operation_parser_js_1.parseValueBinaryOperationOrExpression)(args)),
27
28
  });
28
29
  }
29
30
  whereRef(lhs, op, rhs) {
30
- return new UpdateQueryBuilder({
31
+ return new _a({
31
32
  ...this.#props,
32
33
  queryNode: query_node_js_1.QueryNode.cloneWithWhere(this.#props.queryNode, (0, binary_operation_parser_js_1.parseReferentialBinaryOperation)(lhs, op, rhs)),
33
34
  });
34
35
  }
35
36
  clearWhere() {
36
- return new UpdateQueryBuilder({
37
+ return new _a({
37
38
  ...this.#props,
38
39
  queryNode: query_node_js_1.QueryNode.cloneWithoutWhere(this.#props.queryNode),
39
40
  });
@@ -78,13 +79,13 @@ class UpdateQueryBuilder {
78
79
  * ```
79
80
  */
80
81
  top(expression, modifiers) {
81
- return new UpdateQueryBuilder({
82
+ return new _a({
82
83
  ...this.#props,
83
84
  queryNode: query_node_js_1.QueryNode.cloneWithTop(this.#props.queryNode, (0, top_parser_js_1.parseTop)(expression, modifiers)),
84
85
  });
85
86
  }
86
87
  from(from) {
87
- return new UpdateQueryBuilder({
88
+ return new _a({
88
89
  ...this.#props,
89
90
  queryNode: update_query_node_js_1.UpdateQueryNode.cloneWithFromItems(this.#props.queryNode, (0, table_parser_js_1.parseTableExpressionOrList)(from)),
90
91
  });
@@ -102,19 +103,19 @@ class UpdateQueryBuilder {
102
103
  return this.#join('FullJoin', args);
103
104
  }
104
105
  #join(joinType, args) {
105
- return new UpdateQueryBuilder({
106
+ return new _a({
106
107
  ...this.#props,
107
108
  queryNode: query_node_js_1.QueryNode.cloneWithJoin(this.#props.queryNode, (0, join_parser_js_1.parseJoin)(joinType, args)),
108
109
  });
109
110
  }
110
111
  orderBy(...args) {
111
- return new UpdateQueryBuilder({
112
+ return new _a({
112
113
  ...this.#props,
113
114
  queryNode: query_node_js_1.QueryNode.cloneWithOrderByItems(this.#props.queryNode, (0, order_by_parser_js_1.parseOrderBy)(args)),
114
115
  });
115
116
  }
116
117
  clearOrderBy() {
117
- return new UpdateQueryBuilder({
118
+ return new _a({
118
119
  ...this.#props,
119
120
  queryNode: query_node_js_1.QueryNode.cloneWithoutOrderBy(this.#props.queryNode),
120
121
  });
@@ -141,37 +142,37 @@ class UpdateQueryBuilder {
141
142
  * ```
142
143
  */
143
144
  limit(limit) {
144
- return new UpdateQueryBuilder({
145
+ return new _a({
145
146
  ...this.#props,
146
147
  queryNode: update_query_node_js_1.UpdateQueryNode.cloneWithLimit(this.#props.queryNode, limit_node_js_1.LimitNode.create((0, value_parser_js_1.parseValueExpression)(limit))),
147
148
  });
148
149
  }
149
150
  set(...args) {
150
- return new UpdateQueryBuilder({
151
+ return new _a({
151
152
  ...this.#props,
152
153
  queryNode: update_query_node_js_1.UpdateQueryNode.cloneWithUpdates(this.#props.queryNode, (0, update_set_parser_js_1.parseUpdate)(...args)),
153
154
  });
154
155
  }
155
156
  returning(selection) {
156
- return new UpdateQueryBuilder({
157
+ return new _a({
157
158
  ...this.#props,
158
159
  queryNode: query_node_js_1.QueryNode.cloneWithReturning(this.#props.queryNode, (0, select_parser_js_1.parseSelectArg)(selection)),
159
160
  });
160
161
  }
161
162
  returningAll(table) {
162
- return new UpdateQueryBuilder({
163
+ return new _a({
163
164
  ...this.#props,
164
165
  queryNode: query_node_js_1.QueryNode.cloneWithReturning(this.#props.queryNode, (0, select_parser_js_1.parseSelectAll)(table)),
165
166
  });
166
167
  }
167
168
  output(args) {
168
- return new UpdateQueryBuilder({
169
+ return new _a({
169
170
  ...this.#props,
170
171
  queryNode: query_node_js_1.QueryNode.cloneWithOutput(this.#props.queryNode, (0, select_parser_js_1.parseSelectArg)(args)),
171
172
  });
172
173
  }
173
174
  outputAll(table) {
174
- return new UpdateQueryBuilder({
175
+ return new _a({
175
176
  ...this.#props,
176
177
  queryNode: query_node_js_1.QueryNode.cloneWithOutput(this.#props.queryNode, (0, select_parser_js_1.parseSelectAll)(table)),
177
178
  });
@@ -200,7 +201,7 @@ class UpdateQueryBuilder {
200
201
  * ```
201
202
  */
202
203
  modifyEnd(modifier) {
203
- return new UpdateQueryBuilder({
204
+ return new _a({
204
205
  ...this.#props,
205
206
  queryNode: query_node_js_1.QueryNode.cloneWithEndModifier(this.#props.queryNode, modifier.toOperationNode()),
206
207
  });
@@ -225,7 +226,7 @@ class UpdateQueryBuilder {
225
226
  * ```
226
227
  */
227
228
  clearReturning() {
228
- return new UpdateQueryBuilder({
229
+ return new _a({
229
230
  ...this.#props,
230
231
  queryNode: query_node_js_1.QueryNode.cloneWithoutReturning(this.#props.queryNode),
231
232
  });
@@ -305,7 +306,7 @@ class UpdateQueryBuilder {
305
306
  if (condition) {
306
307
  return func(this);
307
308
  }
308
- return new UpdateQueryBuilder({
309
+ return new _a({
309
310
  ...this.#props,
310
311
  });
311
312
  }
@@ -316,7 +317,7 @@ class UpdateQueryBuilder {
316
317
  * returns a copy of this `UpdateQueryBuilder` with a new output type.
317
318
  */
318
319
  $castTo() {
319
- return new UpdateQueryBuilder(this.#props);
320
+ return new _a(this.#props);
320
321
  }
321
322
  /**
322
323
  * Narrows (parts of) the output type of the query.
@@ -377,7 +378,7 @@ class UpdateQueryBuilder {
377
378
  * ```
378
379
  */
379
380
  $narrowType() {
380
- return new UpdateQueryBuilder(this.#props);
381
+ return new _a(this.#props);
381
382
  }
382
383
  /**
383
384
  * Asserts that query's output row type equals the given type `T`.
@@ -434,13 +435,13 @@ class UpdateQueryBuilder {
434
435
  * ```
435
436
  */
436
437
  $assertType() {
437
- return new UpdateQueryBuilder(this.#props);
438
+ return new _a(this.#props);
438
439
  }
439
440
  /**
440
441
  * Returns a copy of this UpdateQueryBuilder instance with the given plugin installed.
441
442
  */
442
443
  withPlugin(plugin) {
443
- return new UpdateQueryBuilder({
444
+ return new _a({
444
445
  ...this.#props,
445
446
  executor: this.#props.executor.withPlugin(plugin),
446
447
  });
@@ -503,7 +504,7 @@ class UpdateQueryBuilder {
503
504
  }
504
505
  }
505
506
  async explain(format, options) {
506
- const builder = new UpdateQueryBuilder({
507
+ const builder = new _a({
507
508
  ...this.#props,
508
509
  queryNode: query_node_js_1.QueryNode.cloneWithExplain(this.#props.queryNode, format, options),
509
510
  });
@@ -511,3 +512,4 @@ class UpdateQueryBuilder {
511
512
  }
512
513
  }
513
514
  exports.UpdateQueryBuilder = UpdateQueryBuilder;
515
+ _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}`;
@@ -71,27 +71,29 @@ export class PostgresIntrospector {
71
71
  };
72
72
  }
73
73
  #parseTableMetadata(columns) {
74
- return columns.reduce((tables, it) => {
75
- let table = tables.find((tbl) => tbl.name === it.table && tbl.schema === it.schema);
76
- if (!table) {
77
- table = freeze({
78
- name: it.table,
79
- isView: it.table_type === 'v',
80
- schema: it.schema,
74
+ const tableDictionary = new Map();
75
+ for (let i = 0, len = columns.length; i < len; i++) {
76
+ const column = columns[i];
77
+ const { schema, table } = column;
78
+ const tableKey = `schema:${schema};table:${table}`;
79
+ if (!tableDictionary.has(tableKey)) {
80
+ tableDictionary.set(tableKey, freeze({
81
81
  columns: [],
82
- });
83
- tables.push(table);
82
+ isView: column.table_type === 'v',
83
+ name: table,
84
+ schema,
85
+ }));
84
86
  }
85
- table.columns.push(freeze({
86
- name: it.column,
87
- dataType: it.type,
88
- dataTypeSchema: it.type_schema,
89
- isNullable: !it.not_null,
90
- isAutoIncrementing: it.auto_incrementing !== null,
91
- hasDefaultValue: it.has_default,
92
- comment: it.column_description ?? undefined,
87
+ tableDictionary.get(tableKey).columns.push(freeze({
88
+ comment: column.column_description ?? undefined,
89
+ dataType: column.type,
90
+ dataTypeSchema: column.type_schema,
91
+ hasDefaultValue: column.has_default,
92
+ isAutoIncrementing: column.auto_incrementing !== null,
93
+ isNullable: !column.not_null,
94
+ name: column.column,
93
95
  }));
94
- return tables;
95
- }, []);
96
+ }
97
+ return Array.from(tableDictionary.values());
96
98
  }
97
99
  }
@@ -524,7 +524,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
524
524
  * ```
525
525
  *
526
526
  * In the next example a reference tuple is compared to a subquery. Note that
527
- * in this case you need to use the {@link @SelectQueryBuilder.$asTuple | $asTuple}
527
+ * in this case you need to use the {@link SelectQueryBuilder.$asTuple | $asTuple}
528
528
  * function:
529
529
  *
530
530
  * ```ts
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith <project>
4
+ */
1
5
  export * from './kysely.js';
2
6
  export * from './query-creator.js';
3
7
  export * from './expression/expression.js';
package/dist/esm/index.js CHANGED
@@ -1,4 +1,8 @@
1
1
  /// <reference types="./index.d.ts" />
2
+ /**
3
+ * @module
4
+ * @mergeModuleWith <project>
5
+ */
2
6
  export * from './kysely.js';
3
7
  export * from './query-creator.js';
4
8
  export * from './expression/expression.js';