relq 1.0.38 → 1.0.40
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/core/helpers/ConnectedDeleteBuilder.cjs +3 -0
- package/dist/cjs/core/helpers/ConnectedInsertBuilder.cjs +3 -0
- package/dist/cjs/core/helpers/ConnectedSelectBuilder.cjs +16 -0
- package/dist/cjs/core/helpers/ConnectedUpdateBuilder.cjs +3 -0
- package/dist/cjs/select/select-builder.cjs +51 -12
- package/dist/config.d.ts +3 -2
- package/dist/esm/core/helpers/ConnectedDeleteBuilder.js +3 -0
- package/dist/esm/core/helpers/ConnectedInsertBuilder.js +3 -0
- package/dist/esm/core/helpers/ConnectedSelectBuilder.js +16 -0
- package/dist/esm/core/helpers/ConnectedUpdateBuilder.js +3 -0
- package/dist/esm/select/select-builder.js +51 -12
- package/dist/index.d.ts +72 -18
- package/dist/schema-builder.d.ts +3 -2
- package/package.json +1 -1
|
@@ -26,6 +26,9 @@ class ConnectedDeleteBuilder {
|
|
|
26
26
|
return result.metadata.rowCount ?? 0;
|
|
27
27
|
}
|
|
28
28
|
returning(columns) {
|
|
29
|
+
if (columns === null) {
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
29
32
|
this.builder.returning(columns);
|
|
30
33
|
return new ReturningExecutor_1.ReturningExecutor(this.builder, this.relq);
|
|
31
34
|
}
|
|
@@ -49,6 +49,9 @@ class ConnectedInsertBuilder {
|
|
|
49
49
|
return result.metadata.rowCount ?? 0;
|
|
50
50
|
}
|
|
51
51
|
returning(columns) {
|
|
52
|
+
if (columns === null) {
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
52
55
|
this.builder.returning(columns);
|
|
53
56
|
return new ReturningExecutor_1.ReturningExecutor(this.builder, this.relq);
|
|
54
57
|
}
|
|
@@ -28,6 +28,22 @@ class ConnectedSelectBuilder {
|
|
|
28
28
|
this.tableName = tableName;
|
|
29
29
|
this.columns = columns;
|
|
30
30
|
this.schemaKey = schemaKey;
|
|
31
|
+
this.setupColumnResolver();
|
|
32
|
+
}
|
|
33
|
+
setupColumnResolver() {
|
|
34
|
+
const internal = this.relq[methods_1.INTERNAL];
|
|
35
|
+
const tableDef = internal.getTableDef(this.schemaKey || this.tableName);
|
|
36
|
+
if (!tableDef) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const tableColumns = tableDef.$columns || tableDef;
|
|
40
|
+
this.builder.setColumnResolver((column) => {
|
|
41
|
+
const columnDef = tableColumns[column];
|
|
42
|
+
if (columnDef) {
|
|
43
|
+
return columnDef.$sqlName || columnDef.$name || camelToSnake(column);
|
|
44
|
+
}
|
|
45
|
+
return camelToSnake(column);
|
|
46
|
+
});
|
|
31
47
|
}
|
|
32
48
|
where(callback) {
|
|
33
49
|
this.builder.where(callback);
|
|
@@ -27,6 +27,9 @@ class ConnectedUpdateBuilder {
|
|
|
27
27
|
return result.metadata.rowCount ?? 0;
|
|
28
28
|
}
|
|
29
29
|
returning(columns) {
|
|
30
|
+
if (columns === null) {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
30
33
|
this.builder.returning(columns);
|
|
31
34
|
return new ReturningExecutor_1.ReturningExecutor(this.builder, this.relq);
|
|
32
35
|
}
|
|
@@ -21,12 +21,47 @@ class SelectBuilder {
|
|
|
21
21
|
distinctOnColumns = [];
|
|
22
22
|
lockingClause;
|
|
23
23
|
unionQueries = [];
|
|
24
|
+
columnResolver;
|
|
24
25
|
constructor(tableName, columns) {
|
|
25
26
|
this.tableName = tableName;
|
|
26
27
|
if (columns) {
|
|
27
28
|
this.selectColumns = Array.isArray(columns) ? columns : [columns];
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
setColumnResolver(resolver) {
|
|
32
|
+
this.columnResolver = resolver;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
transformConditionColumns(conditions) {
|
|
36
|
+
if (!this.columnResolver) {
|
|
37
|
+
return conditions;
|
|
38
|
+
}
|
|
39
|
+
return conditions.map(cond => {
|
|
40
|
+
if (!cond.column) {
|
|
41
|
+
return cond;
|
|
42
|
+
}
|
|
43
|
+
if (cond.method === 'raw') {
|
|
44
|
+
return cond;
|
|
45
|
+
}
|
|
46
|
+
if (cond.method === 'or' || cond.method === 'and') {
|
|
47
|
+
return {
|
|
48
|
+
...cond,
|
|
49
|
+
values: this.transformConditionColumns(cond.values)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (cond.column.includes('.')) {
|
|
53
|
+
const [tableRef, colName] = cond.column.split('.');
|
|
54
|
+
return {
|
|
55
|
+
...cond,
|
|
56
|
+
column: `${tableRef}.${this.columnResolver(colName)}`
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
...cond,
|
|
61
|
+
column: this.columnResolver(cond.column)
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
30
65
|
setTableAlias(alias) {
|
|
31
66
|
this.tableAlias = alias;
|
|
32
67
|
return this;
|
|
@@ -273,18 +308,20 @@ class SelectBuilder {
|
|
|
273
308
|
query += ' ' + structuredJoinSQL;
|
|
274
309
|
}
|
|
275
310
|
if (this.whereConditions.length > 0) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
311
|
+
let conditions = this.transformConditionColumns(this.whereConditions);
|
|
312
|
+
if (hasJoins) {
|
|
313
|
+
conditions = this.qualifyWhereConditions(conditions, tableRef);
|
|
314
|
+
}
|
|
279
315
|
query += ' WHERE ' + (0, condition_collector_1.buildConditionsSQL)(conditions);
|
|
280
316
|
}
|
|
281
317
|
if (this.groupByColumns.length > 0) {
|
|
282
318
|
query += ' GROUP BY ' + this.groupByColumns.map(col => pg_format_1.default.ident(col)).join(', ');
|
|
283
319
|
}
|
|
284
320
|
if (this.havingConditions.length > 0) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
321
|
+
let havingConds = this.transformConditionColumns(this.havingConditions);
|
|
322
|
+
if (hasJoins) {
|
|
323
|
+
havingConds = this.qualifyWhereConditions(havingConds, tableRef);
|
|
324
|
+
}
|
|
288
325
|
query += ' HAVING ' + (0, condition_collector_1.buildConditionsSQL)(havingConds);
|
|
289
326
|
}
|
|
290
327
|
if (this.orderByColumns.length > 0) {
|
|
@@ -336,18 +373,20 @@ class SelectBuilder {
|
|
|
336
373
|
query += ' ' + structuredJoinSQL;
|
|
337
374
|
}
|
|
338
375
|
if (this.whereConditions.length > 0) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
376
|
+
let conditions = this.transformConditionColumns(this.whereConditions);
|
|
377
|
+
if (hasJoins) {
|
|
378
|
+
conditions = this.qualifyWhereConditions(conditions, tableRef);
|
|
379
|
+
}
|
|
342
380
|
query += ' WHERE ' + (0, condition_collector_1.buildConditionsSQL)(conditions);
|
|
343
381
|
}
|
|
344
382
|
if (this.groupByColumns.length > 0) {
|
|
345
383
|
query += ' GROUP BY ' + this.groupByColumns.map(col => pg_format_1.default.ident(col)).join(', ');
|
|
346
384
|
}
|
|
347
385
|
if (this.havingConditions.length > 0) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
386
|
+
let havingConds = this.transformConditionColumns(this.havingConditions);
|
|
387
|
+
if (hasJoins) {
|
|
388
|
+
havingConds = this.qualifyWhereConditions(havingConds, tableRef);
|
|
389
|
+
}
|
|
351
390
|
query += ' HAVING ' + (0, condition_collector_1.buildConditionsSQL)(havingConds);
|
|
352
391
|
}
|
|
353
392
|
return query;
|
package/dist/config.d.ts
CHANGED
|
@@ -536,9 +536,10 @@ export type Simplify<T> = {
|
|
|
536
536
|
[K in keyof T]: T[K];
|
|
537
537
|
} & {};
|
|
538
538
|
/**
|
|
539
|
-
* Clean a column type by removing DefaultValue union members
|
|
539
|
+
* Clean a column type by removing DefaultValue union members and symbols
|
|
540
|
+
* (symbols like EMPTY_OBJECT/EMPTY_ARRAY can leak into type inference from $default)
|
|
540
541
|
*/
|
|
541
|
-
export type CleanType<T> = Exclude<T, DefaultValue | (object & DefaultValue)>;
|
|
542
|
+
export type CleanType<T> = Exclude<T, DefaultValue | (object & DefaultValue) | symbol>;
|
|
542
543
|
/**
|
|
543
544
|
* Build SELECT type with smart required/optional:
|
|
544
545
|
* - Required: NOT NULL, PRIMARY KEY, has DEFAULT/GENERATED columns
|
|
@@ -22,6 +22,22 @@ export class ConnectedSelectBuilder {
|
|
|
22
22
|
this.tableName = tableName;
|
|
23
23
|
this.columns = columns;
|
|
24
24
|
this.schemaKey = schemaKey;
|
|
25
|
+
this.setupColumnResolver();
|
|
26
|
+
}
|
|
27
|
+
setupColumnResolver() {
|
|
28
|
+
const internal = this.relq[INTERNAL];
|
|
29
|
+
const tableDef = internal.getTableDef(this.schemaKey || this.tableName);
|
|
30
|
+
if (!tableDef) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const tableColumns = tableDef.$columns || tableDef;
|
|
34
|
+
this.builder.setColumnResolver((column) => {
|
|
35
|
+
const columnDef = tableColumns[column];
|
|
36
|
+
if (columnDef) {
|
|
37
|
+
return columnDef.$sqlName || columnDef.$name || camelToSnake(column);
|
|
38
|
+
}
|
|
39
|
+
return camelToSnake(column);
|
|
40
|
+
});
|
|
25
41
|
}
|
|
26
42
|
where(callback) {
|
|
27
43
|
this.builder.where(callback);
|
|
@@ -15,12 +15,47 @@ export class SelectBuilder {
|
|
|
15
15
|
distinctOnColumns = [];
|
|
16
16
|
lockingClause;
|
|
17
17
|
unionQueries = [];
|
|
18
|
+
columnResolver;
|
|
18
19
|
constructor(tableName, columns) {
|
|
19
20
|
this.tableName = tableName;
|
|
20
21
|
if (columns) {
|
|
21
22
|
this.selectColumns = Array.isArray(columns) ? columns : [columns];
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
setColumnResolver(resolver) {
|
|
26
|
+
this.columnResolver = resolver;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
transformConditionColumns(conditions) {
|
|
30
|
+
if (!this.columnResolver) {
|
|
31
|
+
return conditions;
|
|
32
|
+
}
|
|
33
|
+
return conditions.map(cond => {
|
|
34
|
+
if (!cond.column) {
|
|
35
|
+
return cond;
|
|
36
|
+
}
|
|
37
|
+
if (cond.method === 'raw') {
|
|
38
|
+
return cond;
|
|
39
|
+
}
|
|
40
|
+
if (cond.method === 'or' || cond.method === 'and') {
|
|
41
|
+
return {
|
|
42
|
+
...cond,
|
|
43
|
+
values: this.transformConditionColumns(cond.values)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (cond.column.includes('.')) {
|
|
47
|
+
const [tableRef, colName] = cond.column.split('.');
|
|
48
|
+
return {
|
|
49
|
+
...cond,
|
|
50
|
+
column: `${tableRef}.${this.columnResolver(colName)}`
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...cond,
|
|
55
|
+
column: this.columnResolver(cond.column)
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
24
59
|
setTableAlias(alias) {
|
|
25
60
|
this.tableAlias = alias;
|
|
26
61
|
return this;
|
|
@@ -267,18 +302,20 @@ export class SelectBuilder {
|
|
|
267
302
|
query += ' ' + structuredJoinSQL;
|
|
268
303
|
}
|
|
269
304
|
if (this.whereConditions.length > 0) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
305
|
+
let conditions = this.transformConditionColumns(this.whereConditions);
|
|
306
|
+
if (hasJoins) {
|
|
307
|
+
conditions = this.qualifyWhereConditions(conditions, tableRef);
|
|
308
|
+
}
|
|
273
309
|
query += ' WHERE ' + buildConditionsSQL(conditions);
|
|
274
310
|
}
|
|
275
311
|
if (this.groupByColumns.length > 0) {
|
|
276
312
|
query += ' GROUP BY ' + this.groupByColumns.map(col => format.ident(col)).join(', ');
|
|
277
313
|
}
|
|
278
314
|
if (this.havingConditions.length > 0) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
315
|
+
let havingConds = this.transformConditionColumns(this.havingConditions);
|
|
316
|
+
if (hasJoins) {
|
|
317
|
+
havingConds = this.qualifyWhereConditions(havingConds, tableRef);
|
|
318
|
+
}
|
|
282
319
|
query += ' HAVING ' + buildConditionsSQL(havingConds);
|
|
283
320
|
}
|
|
284
321
|
if (this.orderByColumns.length > 0) {
|
|
@@ -330,18 +367,20 @@ export class SelectBuilder {
|
|
|
330
367
|
query += ' ' + structuredJoinSQL;
|
|
331
368
|
}
|
|
332
369
|
if (this.whereConditions.length > 0) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
370
|
+
let conditions = this.transformConditionColumns(this.whereConditions);
|
|
371
|
+
if (hasJoins) {
|
|
372
|
+
conditions = this.qualifyWhereConditions(conditions, tableRef);
|
|
373
|
+
}
|
|
336
374
|
query += ' WHERE ' + buildConditionsSQL(conditions);
|
|
337
375
|
}
|
|
338
376
|
if (this.groupByColumns.length > 0) {
|
|
339
377
|
query += ' GROUP BY ' + this.groupByColumns.map(col => format.ident(col)).join(', ');
|
|
340
378
|
}
|
|
341
379
|
if (this.havingConditions.length > 0) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
380
|
+
let havingConds = this.transformConditionColumns(this.havingConditions);
|
|
381
|
+
if (hasJoins) {
|
|
382
|
+
havingConds = this.qualifyWhereConditions(havingConds, tableRef);
|
|
383
|
+
}
|
|
345
384
|
query += ' HAVING ' + buildConditionsSQL(havingConds);
|
|
346
385
|
}
|
|
347
386
|
return query;
|
package/dist/index.d.ts
CHANGED
|
@@ -474,9 +474,10 @@ export type Simplify<T> = {
|
|
|
474
474
|
[K in keyof T]: T[K];
|
|
475
475
|
} & {};
|
|
476
476
|
/**
|
|
477
|
-
* Clean a column type by removing DefaultValue union members
|
|
477
|
+
* Clean a column type by removing DefaultValue union members and symbols
|
|
478
|
+
* (symbols like EMPTY_OBJECT/EMPTY_ARRAY can leak into type inference from $default)
|
|
478
479
|
*/
|
|
479
|
-
export type CleanType<T> = Exclude<T, DefaultValue | (object & DefaultValue)>;
|
|
480
|
+
export type CleanType<T> = Exclude<T, DefaultValue | (object & DefaultValue) | symbol>;
|
|
480
481
|
/**
|
|
481
482
|
* Build SELECT type with smart required/optional:
|
|
482
483
|
* - Required: NOT NULL, PRIMARY KEY, has DEFAULT/GENERATED columns
|
|
@@ -1330,10 +1331,23 @@ export declare class SelectBuilder {
|
|
|
1330
1331
|
private distinctOnColumns;
|
|
1331
1332
|
private lockingClause?;
|
|
1332
1333
|
private unionQueries;
|
|
1334
|
+
private columnResolver?;
|
|
1333
1335
|
constructor(tableName: string, columns?: string | Array<string | [
|
|
1334
1336
|
string,
|
|
1335
1337
|
string
|
|
1336
1338
|
]>);
|
|
1339
|
+
/**
|
|
1340
|
+
* Set a column resolver to transform column names (e.g., camelCase to snake_case).
|
|
1341
|
+
* Used by ConnectedSelectBuilder to map TypeScript property names to SQL column names.
|
|
1342
|
+
* @internal
|
|
1343
|
+
*/
|
|
1344
|
+
setColumnResolver(resolver: (column: string) => string): SelectBuilder;
|
|
1345
|
+
/**
|
|
1346
|
+
* Transform column names in conditions using the column resolver.
|
|
1347
|
+
* Recursively handles nested or/and conditions.
|
|
1348
|
+
* @internal
|
|
1349
|
+
*/
|
|
1350
|
+
private transformConditionColumns;
|
|
1337
1351
|
/**
|
|
1338
1352
|
* Set an alias for the main table.
|
|
1339
1353
|
* @internal Used by ConnectedSelectBuilder for self-joins
|
|
@@ -6038,6 +6052,9 @@ export interface JoinManyInternals extends JoinConditionInternals {
|
|
|
6038
6052
|
toWhereSQL(): string;
|
|
6039
6053
|
getInnerJoins(): InnerJoinSpec[];
|
|
6040
6054
|
}
|
|
6055
|
+
type Prettify$1<T> = {
|
|
6056
|
+
[K in keyof T]: T[K];
|
|
6057
|
+
} & {};
|
|
6041
6058
|
/**
|
|
6042
6059
|
* Extract only actual column names from a table type
|
|
6043
6060
|
* Uses $inferSelect if available (Drizzle tables), otherwise keyof
|
|
@@ -6048,10 +6065,11 @@ export type ColumnKeys<T> = T extends {
|
|
|
6048
6065
|
/**
|
|
6049
6066
|
* Pick columns from a table's row type
|
|
6050
6067
|
* Handles both table definitions (with $inferSelect) and plain interfaces
|
|
6068
|
+
* Uses Prettify to flatten the type for better IDE display
|
|
6051
6069
|
*/
|
|
6052
6070
|
export type PickColumns<T, K extends string> = T extends {
|
|
6053
6071
|
$inferSelect: infer TSelect;
|
|
6054
|
-
} ? Pick<TSelect, K & keyof TSelect
|
|
6072
|
+
} ? Prettify$1<Pick<TSelect, K & keyof TSelect>> : Prettify$1<Pick<T, K & keyof T>>;
|
|
6055
6073
|
type ColumnValue$1<T, K extends ColumnKeys<T>> = T extends {
|
|
6056
6074
|
$inferSelect: infer TSelect;
|
|
6057
6075
|
} ? K extends keyof TSelect ? TSelect[K] : unknown : K extends keyof T ? T[K] : unknown;
|
|
@@ -6562,12 +6580,22 @@ declare class ConnectedDeleteBuilder<TTable = any> {
|
|
|
6562
6580
|
/**
|
|
6563
6581
|
* Set RETURNING clause - returns executor with typed run()
|
|
6564
6582
|
* Use '*' to return all columns, or specify column names
|
|
6583
|
+
* Pass null to skip RETURNING clause (useful for conditional returning)
|
|
6565
6584
|
*/
|
|
6566
|
-
returning
|
|
6585
|
+
returning(columns: null): this;
|
|
6586
|
+
returning(columns: "*"): ReturningExecutor<TTable extends {
|
|
6587
|
+
$inferSelect: infer S;
|
|
6588
|
+
} ? S : TTable>;
|
|
6589
|
+
returning<K extends string & ColumnName<TTable>>(columns: K | K[]): ReturningExecutor<Prettify<Pick<TTable extends {
|
|
6590
|
+
$inferSelect: infer S;
|
|
6591
|
+
} ? S : TTable, K & keyof (TTable extends {
|
|
6592
|
+
$inferSelect: infer S;
|
|
6593
|
+
} ? S : TTable)>>>;
|
|
6594
|
+
returning<K extends string & ColumnName<TTable>>(columns: K[] | null): this | ReturningExecutor<Prettify<Pick<TTable extends {
|
|
6567
6595
|
$inferSelect: infer S;
|
|
6568
6596
|
} ? S : TTable, K & keyof (TTable extends {
|
|
6569
6597
|
$inferSelect: infer S;
|
|
6570
|
-
} ? S : TTable)
|
|
6598
|
+
} ? S : TTable)>>>;
|
|
6571
6599
|
}
|
|
6572
6600
|
declare class ConnectedInsertBuilder<TTable = any> {
|
|
6573
6601
|
private builder;
|
|
@@ -6606,12 +6634,22 @@ declare class ConnectedInsertBuilder<TTable = any> {
|
|
|
6606
6634
|
/**
|
|
6607
6635
|
* Set RETURNING clause - returns executor with typed run()
|
|
6608
6636
|
* Use '*' to return all columns, or specify column names
|
|
6637
|
+
* Pass null to skip RETURNING clause (useful for conditional returning)
|
|
6609
6638
|
*/
|
|
6610
|
-
returning
|
|
6639
|
+
returning(columns: null): this;
|
|
6640
|
+
returning(columns: "*"): ReturningExecutor<TTable extends {
|
|
6641
|
+
$inferSelect: infer S;
|
|
6642
|
+
} ? S : TTable>;
|
|
6643
|
+
returning<K extends string & ColumnName<TTable>>(columns: K | K[]): ReturningExecutor<Prettify<Pick<TTable extends {
|
|
6644
|
+
$inferSelect: infer S;
|
|
6645
|
+
} ? S : TTable, K & keyof (TTable extends {
|
|
6646
|
+
$inferSelect: infer S;
|
|
6647
|
+
} ? S : TTable)>>>;
|
|
6648
|
+
returning<K extends string & ColumnName<TTable>>(columns: K[] | null): this | ReturningExecutor<Prettify<Pick<TTable extends {
|
|
6611
6649
|
$inferSelect: infer S;
|
|
6612
6650
|
} ? S : TTable, K & keyof (TTable extends {
|
|
6613
6651
|
$inferSelect: infer S;
|
|
6614
|
-
} ? S : TTable)
|
|
6652
|
+
} ? S : TTable)>>>;
|
|
6615
6653
|
}
|
|
6616
6654
|
declare class ConnectedUpdateBuilder<TTable = any> {
|
|
6617
6655
|
private builder;
|
|
@@ -6631,12 +6669,22 @@ declare class ConnectedUpdateBuilder<TTable = any> {
|
|
|
6631
6669
|
/**
|
|
6632
6670
|
* Set RETURNING clause - returns executor with typed run()
|
|
6633
6671
|
* Use '*' to return all columns, or specify column names
|
|
6672
|
+
* Pass null to skip RETURNING clause (useful for conditional returning)
|
|
6634
6673
|
*/
|
|
6635
|
-
returning
|
|
6674
|
+
returning(columns: null): this;
|
|
6675
|
+
returning(columns: "*"): ReturningExecutor<TTable extends {
|
|
6676
|
+
$inferSelect: infer S;
|
|
6677
|
+
} ? S : TTable>;
|
|
6678
|
+
returning<K extends string & ColumnName<TTable>>(columns: K | K[]): ReturningExecutor<Prettify<Pick<TTable extends {
|
|
6679
|
+
$inferSelect: infer S;
|
|
6680
|
+
} ? S : TTable, K & keyof (TTable extends {
|
|
6681
|
+
$inferSelect: infer S;
|
|
6682
|
+
} ? S : TTable)>>>;
|
|
6683
|
+
returning<K extends string & ColumnName<TTable>>(columns: K[] | null): this | ReturningExecutor<Prettify<Pick<TTable extends {
|
|
6636
6684
|
$inferSelect: infer S;
|
|
6637
6685
|
} ? S : TTable, K & keyof (TTable extends {
|
|
6638
6686
|
$inferSelect: infer S;
|
|
6639
|
-
} ? S : TTable)
|
|
6687
|
+
} ? S : TTable)>>>;
|
|
6640
6688
|
}
|
|
6641
6689
|
declare class PaginateBuilder<TSchema, TTable, T> {
|
|
6642
6690
|
private relq;
|
|
@@ -7101,7 +7149,7 @@ export type TableAccessor<TSchema, TRelq> = {
|
|
|
7101
7149
|
} & {
|
|
7102
7150
|
[K in keyof TSchema & string]: ConnectedQueryBuilder<TSchema, TSchema[K]>;
|
|
7103
7151
|
};
|
|
7104
|
-
type Prettify$
|
|
7152
|
+
type Prettify$2<T> = {
|
|
7105
7153
|
[K in keyof T]: T[K];
|
|
7106
7154
|
} & {};
|
|
7107
7155
|
/**
|
|
@@ -7109,9 +7157,9 @@ type Prettify$1<T> = {
|
|
|
7109
7157
|
*/
|
|
7110
7158
|
export type InferRowType<TTable> = TTable extends {
|
|
7111
7159
|
$inferSelect: infer TSelect;
|
|
7112
|
-
} ? Prettify$
|
|
7160
|
+
} ? Prettify$2<TSelect> : TTable extends {
|
|
7113
7161
|
$columns: infer TCols;
|
|
7114
|
-
} ? Prettify$
|
|
7162
|
+
} ? Prettify$2<{
|
|
7115
7163
|
[K in keyof TCols]: any;
|
|
7116
7164
|
}> : TTable;
|
|
7117
7165
|
/**
|
|
@@ -7146,6 +7194,12 @@ declare class ConnectedSelectBuilder<TSchema = any, TTable = any, TColumns exten
|
|
|
7146
7194
|
]>) | undefined,
|
|
7147
7195
|
/** Schema key (camelCase) - used for join callback params */
|
|
7148
7196
|
schemaKey?: string | undefined);
|
|
7197
|
+
/**
|
|
7198
|
+
* Set up column resolver to transform property names to SQL column names.
|
|
7199
|
+
* Uses schema metadata to resolve column names.
|
|
7200
|
+
* @internal
|
|
7201
|
+
*/
|
|
7202
|
+
private setupColumnResolver;
|
|
7149
7203
|
where(callback: (q: TypedConditionBuilder<TTable>) => TypedConditionBuilder<TTable>): this;
|
|
7150
7204
|
orderBy(column: ColumnName<TTable>, direction?: "ASC" | "DESC"): this;
|
|
7151
7205
|
limit(count: number): this;
|
|
@@ -7430,13 +7484,13 @@ declare class ConnectedSelectBuilder<TSchema = any, TTable = any, TColumns exten
|
|
|
7430
7484
|
* @param withMetadata - If true, returns { data, metadata }
|
|
7431
7485
|
* @param asRequired - If true, all fields are required (removes optional)
|
|
7432
7486
|
*/
|
|
7433
|
-
all(): Promise<Prettify$
|
|
7487
|
+
all(): Promise<Prettify$2<InferResultType<TSchema, TTable, TColumns> & TJoined>[]>;
|
|
7434
7488
|
all(withMetadata: true): Promise<{
|
|
7435
|
-
data: Prettify$
|
|
7489
|
+
data: Prettify$2<InferResultType<TSchema, TTable, TColumns> & TJoined>[];
|
|
7436
7490
|
metadata: RelqMetadata;
|
|
7437
7491
|
}>;
|
|
7438
7492
|
all<R extends boolean>(withMetadata: true, asRequired: R): Promise<{
|
|
7439
|
-
data: Prettify$
|
|
7493
|
+
data: Prettify$2<R extends true ? Required<InferResultType<TSchema, TTable, TColumns> & TJoined> : InferResultType<TSchema, TTable, TColumns> & TJoined>[];
|
|
7440
7494
|
metadata: RelqMetadata;
|
|
7441
7495
|
}>;
|
|
7442
7496
|
/**
|
|
@@ -7445,13 +7499,13 @@ declare class ConnectedSelectBuilder<TSchema = any, TTable = any, TColumns exten
|
|
|
7445
7499
|
* @param withMetadata - If true, returns { data, metadata }
|
|
7446
7500
|
* @param asRequired - If true, all fields are required (removes optional)
|
|
7447
7501
|
*/
|
|
7448
|
-
get(): Promise<Prettify$
|
|
7502
|
+
get(): Promise<Prettify$2<InferResultType<TSchema, TTable, TColumns> & TJoined> | null>;
|
|
7449
7503
|
get(withMetadata: true): Promise<{
|
|
7450
|
-
data: Prettify$
|
|
7504
|
+
data: Prettify$2<InferResultType<TSchema, TTable, TColumns> & TJoined> | null;
|
|
7451
7505
|
metadata: RelqMetadata;
|
|
7452
7506
|
}>;
|
|
7453
7507
|
get<R extends boolean>(withMetadata: true, asRequired: R): Promise<{
|
|
7454
|
-
data: Prettify$
|
|
7508
|
+
data: Prettify$2<R extends true ? Required<InferResultType<TSchema, TTable, TColumns> & TJoined> : InferResultType<TSchema, TTable, TColumns> & TJoined> | null;
|
|
7455
7509
|
metadata: RelqMetadata;
|
|
7456
7510
|
}>;
|
|
7457
7511
|
/**
|
package/dist/schema-builder.d.ts
CHANGED
|
@@ -2779,9 +2779,10 @@ export type Simplify<T> = {
|
|
|
2779
2779
|
[K in keyof T]: T[K];
|
|
2780
2780
|
} & {};
|
|
2781
2781
|
/**
|
|
2782
|
-
* Clean a column type by removing DefaultValue union members
|
|
2782
|
+
* Clean a column type by removing DefaultValue union members and symbols
|
|
2783
|
+
* (symbols like EMPTY_OBJECT/EMPTY_ARRAY can leak into type inference from $default)
|
|
2783
2784
|
*/
|
|
2784
|
-
export type CleanType<T> = Exclude<T, DefaultValue | (object & DefaultValue)>;
|
|
2785
|
+
export type CleanType<T> = Exclude<T, DefaultValue | (object & DefaultValue) | symbol>;
|
|
2785
2786
|
/**
|
|
2786
2787
|
* Build SELECT type with smart required/optional:
|
|
2787
2788
|
* - Required: NOT NULL, PRIMARY KEY, has DEFAULT/GENERATED columns
|