@prisma-next/sql-orm-lane 0.1.0-pr.45.2 → 0.1.0-pr.46.2
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/{chunk-KQPLODPT.js → chunk-AIYGMPVJ.js} +208 -166
- package/dist/chunk-AIYGMPVJ.js.map +1 -0
- package/dist/exports/orm.d.ts +1 -1
- package/dist/exports/orm.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/{orm-DAnGd7z2.d.ts → orm-Bi3TkJHa.d.ts} +7 -7
- package/package.json +9 -11
- package/dist/chunk-KQPLODPT.js.map +0 -1
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createDeleteAst,
|
|
13
13
|
createInsertAst,
|
|
14
14
|
createJoinOnExpr,
|
|
15
|
+
createNullCheckExpr,
|
|
15
16
|
createOrderByItem,
|
|
16
17
|
createParamRef,
|
|
17
18
|
createSelectAst,
|
|
@@ -93,10 +94,10 @@ function errorMissingAlias(index) {
|
|
|
93
94
|
throw planInvalid(`Missing alias at index ${index}`);
|
|
94
95
|
}
|
|
95
96
|
function errorMissingColumn(alias, index) {
|
|
96
|
-
throw planInvalid(`Missing column for alias ${alias} at index ${index}`);
|
|
97
|
+
throw planInvalid(`Missing column for alias "${alias}" at index ${index}`);
|
|
97
98
|
}
|
|
98
99
|
function errorInvalidColumn(alias, index) {
|
|
99
|
-
throw planInvalid(`Invalid column for alias ${alias} at index ${index}`);
|
|
100
|
+
throw planInvalid(`Invalid column for alias "${alias}" at index ${index}`);
|
|
100
101
|
}
|
|
101
102
|
function errorFailedToBuildWhereClause() {
|
|
102
103
|
throw planInvalid("Failed to build WHERE clause");
|
|
@@ -113,37 +114,115 @@ function assertParameterExists(paramsMap, paramName) {
|
|
|
113
114
|
return paramsMap[paramName];
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
// src/utils/guards.ts
|
|
118
|
+
import { getColumnMeta, isParamPlaceholder } from "@prisma-next/sql-relational-core/utils/guards";
|
|
119
|
+
function extractBaseColumnRef(expr) {
|
|
120
|
+
if (expr.kind === "col") {
|
|
121
|
+
return expr;
|
|
122
|
+
}
|
|
123
|
+
return extractBaseColumnRef(expr.self);
|
|
124
|
+
}
|
|
125
|
+
function collectColumnRefs(expr) {
|
|
126
|
+
if (expr.kind === "col") {
|
|
127
|
+
return [expr];
|
|
128
|
+
}
|
|
129
|
+
if (expr.kind === "operation") {
|
|
130
|
+
const refs = collectColumnRefs(expr.self);
|
|
131
|
+
for (const arg of expr.args) {
|
|
132
|
+
refs.push(...collectColumnRefs(arg));
|
|
133
|
+
}
|
|
134
|
+
return refs;
|
|
135
|
+
}
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
function isOperationExpr(expr) {
|
|
139
|
+
return expr != null && expr.kind === "operation";
|
|
140
|
+
}
|
|
141
|
+
function isExpressionBuilder(value) {
|
|
142
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "expression";
|
|
143
|
+
}
|
|
144
|
+
function extractExpression(builder) {
|
|
145
|
+
if (isExpressionBuilder(builder)) {
|
|
146
|
+
return builder.expr;
|
|
147
|
+
}
|
|
148
|
+
const colBuilder = builder;
|
|
149
|
+
return {
|
|
150
|
+
kind: "col",
|
|
151
|
+
table: colBuilder.table,
|
|
152
|
+
column: colBuilder.column
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function getColumnInfo(expr) {
|
|
156
|
+
if (isExpressionBuilder(expr)) {
|
|
157
|
+
const baseCol = extractBaseColumnRef(expr.expr);
|
|
158
|
+
return { table: baseCol.table, column: baseCol.column };
|
|
159
|
+
}
|
|
160
|
+
const colBuilder = expr;
|
|
161
|
+
return { table: colBuilder.table, column: colBuilder.column };
|
|
162
|
+
}
|
|
163
|
+
function isColumnBuilder(value) {
|
|
164
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "column";
|
|
165
|
+
}
|
|
166
|
+
|
|
116
167
|
// src/selection/predicates.ts
|
|
117
168
|
function buildWhereExpr(where, contract, paramsMap, descriptors, values) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
169
|
+
if (where.kind === "nullCheck") {
|
|
170
|
+
const expr = extractExpression(where.expr);
|
|
171
|
+
return {
|
|
172
|
+
expr: createNullCheckExpr(where.op, expr),
|
|
173
|
+
paramName: ""
|
|
174
|
+
};
|
|
122
175
|
}
|
|
123
|
-
const value = paramsMap[paramName];
|
|
124
|
-
const index = values.push(value);
|
|
125
176
|
let leftExpr;
|
|
126
177
|
let codecId;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
178
|
+
let rightExpr;
|
|
179
|
+
let paramName;
|
|
180
|
+
leftExpr = extractExpression(where.left);
|
|
181
|
+
if (leftExpr.kind === "col") {
|
|
182
|
+
const contractTable = contract.storage.tables[leftExpr.table];
|
|
183
|
+
if (!contractTable) {
|
|
184
|
+
errorUnknownTable(leftExpr.table);
|
|
185
|
+
}
|
|
186
|
+
const columnMeta = contractTable.columns[leftExpr.column];
|
|
187
|
+
if (columnMeta) {
|
|
188
|
+
codecId = columnMeta.codecId;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (isParamPlaceholder(where.right)) {
|
|
192
|
+
const placeholder = where.right;
|
|
193
|
+
paramName = placeholder.name;
|
|
194
|
+
if (!Object.hasOwn(paramsMap, paramName)) {
|
|
195
|
+
errorMissingParameter(paramName);
|
|
196
|
+
}
|
|
197
|
+
const value = paramsMap[paramName];
|
|
198
|
+
const index = values.push(value);
|
|
199
|
+
if (leftExpr.kind === "col") {
|
|
200
|
+
const contractTable = contract.storage.tables[leftExpr.table];
|
|
201
|
+
const columnMeta = contractTable?.columns[leftExpr.column];
|
|
202
|
+
const builderColumnMeta = isColumnBuilder(where.left) ? getColumnMeta(where.left) : isExpressionBuilder(where.left) ? where.left.columnMeta : void 0;
|
|
203
|
+
descriptors.push({
|
|
204
|
+
name: paramName,
|
|
205
|
+
source: "dsl",
|
|
206
|
+
refs: { table: leftExpr.table, column: leftExpr.column },
|
|
207
|
+
// Only include nullable if builderColumnMeta has it (don't fall back to contract)
|
|
208
|
+
...typeof builderColumnMeta?.nullable === "boolean" ? { nullable: builderColumnMeta.nullable } : {}
|
|
209
|
+
});
|
|
210
|
+
augmentDescriptorWithColumnMeta(descriptors, columnMeta);
|
|
211
|
+
}
|
|
212
|
+
rightExpr = createParamRef(index, paramName);
|
|
213
|
+
} else if (isColumnBuilder(where.right)) {
|
|
214
|
+
const { table, column } = getColumnInfo(where.right);
|
|
215
|
+
const contractTable = contract.storage.tables[table];
|
|
216
|
+
if (!contractTable) {
|
|
217
|
+
errorUnknownTable(table);
|
|
218
|
+
}
|
|
219
|
+
rightExpr = createColumnRef(table, column);
|
|
220
|
+
paramName = "";
|
|
130
221
|
} else {
|
|
131
|
-
|
|
132
|
-
const meta = colBuilder.columnMeta ?? {};
|
|
133
|
-
descriptors.push({
|
|
134
|
-
name: paramName,
|
|
135
|
-
source: "dsl",
|
|
136
|
-
refs: { table: colBuilder.table, column: colBuilder.column },
|
|
137
|
-
...typeof meta.nullable === "boolean" ? { nullable: meta.nullable } : {}
|
|
138
|
-
});
|
|
139
|
-
const contractTable = contract.storage.tables[colBuilder.table];
|
|
140
|
-
const columnMeta = contractTable?.columns[colBuilder.column];
|
|
141
|
-
codecId = columnMeta?.codecId;
|
|
142
|
-
augmentDescriptorWithColumnMeta(descriptors, columnMeta);
|
|
143
|
-
leftExpr = createColumnRef(colBuilder.table, colBuilder.column);
|
|
222
|
+
errorFailedToBuildWhereClause();
|
|
144
223
|
}
|
|
145
224
|
return {
|
|
146
|
-
expr: createBinaryExpr(where.op, leftExpr,
|
|
225
|
+
expr: createBinaryExpr(where.op, leftExpr, rightExpr),
|
|
147
226
|
...codecId ? { codecId } : {},
|
|
148
227
|
paramName
|
|
149
228
|
};
|
|
@@ -590,50 +669,13 @@ var OrmRelationFilterBuilderImpl = class _OrmRelationFilterBuilderImpl {
|
|
|
590
669
|
// src/plan/plan-assembly.ts
|
|
591
670
|
import { planInvalid as planInvalid4 } from "@prisma-next/plan";
|
|
592
671
|
import { compact } from "@prisma-next/sql-relational-core/ast";
|
|
593
|
-
|
|
594
|
-
// src/utils/guards.ts
|
|
595
|
-
function extractBaseColumnRef(expr) {
|
|
596
|
-
if (expr.kind === "col") {
|
|
597
|
-
return expr;
|
|
598
|
-
}
|
|
599
|
-
return extractBaseColumnRef(expr.self);
|
|
600
|
-
}
|
|
601
|
-
function collectColumnRefs(expr) {
|
|
602
|
-
if (expr.kind === "col") {
|
|
603
|
-
return [expr];
|
|
604
|
-
}
|
|
605
|
-
if (expr.kind === "operation") {
|
|
606
|
-
const refs = collectColumnRefs(expr.self);
|
|
607
|
-
for (const arg of expr.args) {
|
|
608
|
-
refs.push(...collectColumnRefs(arg));
|
|
609
|
-
}
|
|
610
|
-
return refs;
|
|
611
|
-
}
|
|
612
|
-
return [];
|
|
613
|
-
}
|
|
614
|
-
function isOperationExpr(expr) {
|
|
615
|
-
return typeof expr === "object" && expr !== null && "kind" in expr && expr.kind === "operation";
|
|
616
|
-
}
|
|
617
|
-
function getColumnInfo(expr) {
|
|
618
|
-
if (isOperationExpr(expr)) {
|
|
619
|
-
const baseCol = extractBaseColumnRef(expr);
|
|
620
|
-
return { table: baseCol.table, column: baseCol.column };
|
|
621
|
-
}
|
|
622
|
-
const colBuilder = expr;
|
|
623
|
-
return { table: colBuilder.table, column: colBuilder.column };
|
|
624
|
-
}
|
|
625
|
-
function isColumnBuilder(value) {
|
|
626
|
-
return typeof value === "object" && value !== null && "kind" in value && value.kind === "column";
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// src/plan/plan-assembly.ts
|
|
630
672
|
function buildMeta(args) {
|
|
631
673
|
const refsColumns = /* @__PURE__ */ new Map();
|
|
632
674
|
const refsTables = /* @__PURE__ */ new Set([args.table.name]);
|
|
633
675
|
for (const column of args.projection.columns) {
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
636
|
-
const allRefs = collectColumnRefs(
|
|
676
|
+
const expr = extractExpression(column);
|
|
677
|
+
if (isOperationExpr(expr)) {
|
|
678
|
+
const allRefs = collectColumnRefs(expr);
|
|
637
679
|
for (const ref of allRefs) {
|
|
638
680
|
refsColumns.set(`${ref.table}.${ref.column}`, {
|
|
639
681
|
table: ref.table,
|
|
@@ -641,13 +683,10 @@ function buildMeta(args) {
|
|
|
641
683
|
});
|
|
642
684
|
}
|
|
643
685
|
} else {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
column: col.column
|
|
649
|
-
});
|
|
650
|
-
}
|
|
686
|
+
refsColumns.set(`${expr.table}.${expr.column}`, {
|
|
687
|
+
table: expr.table,
|
|
688
|
+
column: expr.column
|
|
689
|
+
});
|
|
651
690
|
}
|
|
652
691
|
}
|
|
653
692
|
if (args.includes) {
|
|
@@ -675,11 +714,24 @@ function buildMeta(args) {
|
|
|
675
714
|
}
|
|
676
715
|
}
|
|
677
716
|
if (include.childWhere) {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
table
|
|
681
|
-
|
|
682
|
-
|
|
717
|
+
if (include.childWhere.kind === "binary") {
|
|
718
|
+
const colInfo = getColumnInfo(include.childWhere.left);
|
|
719
|
+
refsColumns.set(`${colInfo.table}.${colInfo.column}`, {
|
|
720
|
+
table: colInfo.table,
|
|
721
|
+
column: colInfo.column
|
|
722
|
+
});
|
|
723
|
+
} else if (include.childWhere.kind === "nullCheck") {
|
|
724
|
+
const colInfo = getColumnInfo(include.childWhere.expr);
|
|
725
|
+
refsColumns.set(`${colInfo.table}.${colInfo.column}`, {
|
|
726
|
+
table: colInfo.table,
|
|
727
|
+
column: colInfo.column
|
|
728
|
+
});
|
|
729
|
+
} else {
|
|
730
|
+
const _exhaustive = include.childWhere;
|
|
731
|
+
throw new Error(
|
|
732
|
+
`Unsupported predicate builder kind: ${_exhaustive.kind}`
|
|
733
|
+
);
|
|
734
|
+
}
|
|
683
735
|
}
|
|
684
736
|
if (include.childOrderBy) {
|
|
685
737
|
const orderBy = include.childOrderBy;
|
|
@@ -694,10 +746,24 @@ function buildMeta(args) {
|
|
|
694
746
|
}
|
|
695
747
|
}
|
|
696
748
|
if (args.where) {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
749
|
+
let whereExprBuilder;
|
|
750
|
+
switch (args.where.kind) {
|
|
751
|
+
case "binary":
|
|
752
|
+
whereExprBuilder = args.where.left;
|
|
753
|
+
break;
|
|
754
|
+
case "nullCheck":
|
|
755
|
+
whereExprBuilder = args.where.expr;
|
|
756
|
+
break;
|
|
757
|
+
default: {
|
|
758
|
+
const _exhaustive = args.where;
|
|
759
|
+
throw new Error(
|
|
760
|
+
`Unsupported predicate builder kind: ${_exhaustive.kind}`
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
const expr = extractExpression(whereExprBuilder);
|
|
765
|
+
if (isOperationExpr(expr)) {
|
|
766
|
+
const allRefs = collectColumnRefs(expr);
|
|
701
767
|
for (const ref of allRefs) {
|
|
702
768
|
refsColumns.set(`${ref.table}.${ref.column}`, {
|
|
703
769
|
table: ref.table,
|
|
@@ -705,21 +771,19 @@ function buildMeta(args) {
|
|
|
705
771
|
});
|
|
706
772
|
}
|
|
707
773
|
} else {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
column: colBuilder.column
|
|
713
|
-
});
|
|
714
|
-
}
|
|
774
|
+
refsColumns.set(`${expr.table}.${expr.column}`, {
|
|
775
|
+
table: expr.table,
|
|
776
|
+
column: expr.column
|
|
777
|
+
});
|
|
715
778
|
}
|
|
716
779
|
}
|
|
717
780
|
if (args.orderBy) {
|
|
718
781
|
const orderBy = args.orderBy;
|
|
719
782
|
const orderByExpr = orderBy.expr;
|
|
720
783
|
if (orderByExpr) {
|
|
721
|
-
|
|
722
|
-
|
|
784
|
+
const expr = extractExpression(orderByExpr);
|
|
785
|
+
if (isOperationExpr(expr)) {
|
|
786
|
+
const allRefs = collectColumnRefs(expr);
|
|
723
787
|
for (const ref of allRefs) {
|
|
724
788
|
refsColumns.set(`${ref.table}.${ref.column}`, {
|
|
725
789
|
table: ref.table,
|
|
@@ -727,13 +791,10 @@ function buildMeta(args) {
|
|
|
727
791
|
});
|
|
728
792
|
}
|
|
729
793
|
} else {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
column: colBuilder.column
|
|
735
|
-
});
|
|
736
|
-
}
|
|
794
|
+
refsColumns.set(`${expr.table}.${expr.column}`, {
|
|
795
|
+
table: expr.table,
|
|
796
|
+
column: expr.column
|
|
797
|
+
});
|
|
737
798
|
}
|
|
738
799
|
}
|
|
739
800
|
}
|
|
@@ -747,15 +808,11 @@ function buildMeta(args) {
|
|
|
747
808
|
if (!column) {
|
|
748
809
|
throw planInvalid4(`Missing column for alias ${alias} at index ${index}`);
|
|
749
810
|
}
|
|
750
|
-
const
|
|
751
|
-
if (
|
|
752
|
-
return [alias, `
|
|
753
|
-
}
|
|
754
|
-
const operationExpr = col._operationExpr;
|
|
755
|
-
if (operationExpr) {
|
|
756
|
-
return [alias, `operation:${operationExpr.method}`];
|
|
811
|
+
const expr = extractExpression(column);
|
|
812
|
+
if (isOperationExpr(expr)) {
|
|
813
|
+
return [alias, `operation:${expr.method}`];
|
|
757
814
|
}
|
|
758
|
-
return [alias, `${
|
|
815
|
+
return [alias, `${expr.table}.${expr.column}`];
|
|
759
816
|
})
|
|
760
817
|
);
|
|
761
818
|
const projectionTypes = {};
|
|
@@ -768,19 +825,25 @@ function buildMeta(args) {
|
|
|
768
825
|
if (!col) {
|
|
769
826
|
continue;
|
|
770
827
|
}
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
773
|
-
if (
|
|
774
|
-
projectionTypes[alias] =
|
|
775
|
-
} else if (
|
|
776
|
-
projectionTypes[alias] =
|
|
828
|
+
const expr = extractExpression(col);
|
|
829
|
+
if (isOperationExpr(expr)) {
|
|
830
|
+
if (expr.returns.kind === "typeId") {
|
|
831
|
+
projectionTypes[alias] = expr.returns.type;
|
|
832
|
+
} else if (expr.returns.kind === "builtin") {
|
|
833
|
+
projectionTypes[alias] = expr.returns.type;
|
|
777
834
|
}
|
|
778
835
|
} else {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
836
|
+
if (isExpressionBuilder(col)) {
|
|
837
|
+
const codecId = col.columnMeta.codecId;
|
|
838
|
+
if (codecId) {
|
|
839
|
+
projectionTypes[alias] = codecId;
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
const columnMeta = getColumnMeta(col);
|
|
843
|
+
const codecId = columnMeta?.codecId;
|
|
844
|
+
if (codecId) {
|
|
845
|
+
projectionTypes[alias] = codecId;
|
|
846
|
+
}
|
|
784
847
|
}
|
|
785
848
|
}
|
|
786
849
|
}
|
|
@@ -794,17 +857,23 @@ function buildMeta(args) {
|
|
|
794
857
|
if (!column) {
|
|
795
858
|
continue;
|
|
796
859
|
}
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
799
|
-
if (
|
|
800
|
-
projectionCodecs[alias] =
|
|
860
|
+
const expr = extractExpression(column);
|
|
861
|
+
if (isOperationExpr(expr)) {
|
|
862
|
+
if (expr.returns.kind === "typeId") {
|
|
863
|
+
projectionCodecs[alias] = expr.returns.type;
|
|
801
864
|
}
|
|
802
865
|
} else {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
866
|
+
if (isExpressionBuilder(column)) {
|
|
867
|
+
const codecId = column.columnMeta.codecId;
|
|
868
|
+
if (codecId) {
|
|
869
|
+
projectionCodecs[alias] = codecId;
|
|
870
|
+
}
|
|
871
|
+
} else {
|
|
872
|
+
const columnMeta = getColumnMeta(column);
|
|
873
|
+
const codecId = columnMeta?.codecId;
|
|
874
|
+
if (codecId) {
|
|
875
|
+
projectionCodecs[alias] = codecId;
|
|
876
|
+
}
|
|
808
877
|
}
|
|
809
878
|
}
|
|
810
879
|
}
|
|
@@ -861,11 +930,7 @@ function buildOrderByClause(orderBy) {
|
|
|
861
930
|
return void 0;
|
|
862
931
|
}
|
|
863
932
|
const orderByBuilder = orderBy;
|
|
864
|
-
const
|
|
865
|
-
const expr = isOperationExpr(orderExpr) ? orderExpr : (() => {
|
|
866
|
-
const colBuilder = orderExpr;
|
|
867
|
-
return createColumnRef(colBuilder.table, colBuilder.column);
|
|
868
|
-
})();
|
|
933
|
+
const expr = extractExpression(orderByBuilder.expr);
|
|
869
934
|
return [createOrderByItem(expr, orderByBuilder.dir)];
|
|
870
935
|
}
|
|
871
936
|
function buildChildOrderByClause(orderBy) {
|
|
@@ -873,15 +938,7 @@ function buildChildOrderByClause(orderBy) {
|
|
|
873
938
|
return void 0;
|
|
874
939
|
}
|
|
875
940
|
const orderByBuilder = orderBy;
|
|
876
|
-
const
|
|
877
|
-
const expr = (() => {
|
|
878
|
-
if (isOperationExpr(orderExpr)) {
|
|
879
|
-
const baseCol = extractBaseColumnRef(orderExpr);
|
|
880
|
-
return createColumnRef(baseCol.table, baseCol.column);
|
|
881
|
-
}
|
|
882
|
-
const colBuilder = orderExpr;
|
|
883
|
-
return createColumnRef(colBuilder.table, colBuilder.column);
|
|
884
|
-
})();
|
|
941
|
+
const expr = extractExpression(orderByBuilder.expr);
|
|
885
942
|
return [createOrderByItem(expr, orderByBuilder.dir)];
|
|
886
943
|
}
|
|
887
944
|
|
|
@@ -917,7 +974,7 @@ function flattenProjection(projection, tracker, currentPath = []) {
|
|
|
917
974
|
const columns = [];
|
|
918
975
|
for (const [key, value] of Object.entries(projection)) {
|
|
919
976
|
const path = [...currentPath, key];
|
|
920
|
-
if (isColumnBuilder(value)) {
|
|
977
|
+
if (isColumnBuilder(value) || isExpressionBuilder(value)) {
|
|
921
978
|
const alias = tracker.register(path);
|
|
922
979
|
aliases.push(alias);
|
|
923
980
|
columns.push(value);
|
|
@@ -952,7 +1009,7 @@ function buildProjectionState(_table, projection, includes) {
|
|
|
952
1009
|
nullable: true
|
|
953
1010
|
}
|
|
954
1011
|
});
|
|
955
|
-
} else if (isColumnBuilder(value)) {
|
|
1012
|
+
} else if (isColumnBuilder(value) || isExpressionBuilder(value)) {
|
|
956
1013
|
const alias = tracker.register([key]);
|
|
957
1014
|
aliases.push(alias);
|
|
958
1015
|
columns.push(value);
|
|
@@ -1053,13 +1110,8 @@ function buildIncludeAsts(includes, contract, context, modelName, paramsMap, par
|
|
|
1053
1110
|
if (!column) {
|
|
1054
1111
|
errorMissingColumn(alias, i);
|
|
1055
1112
|
}
|
|
1056
|
-
const
|
|
1057
|
-
|
|
1058
|
-
childProjectionItems.push({ alias, expr: operationExpr });
|
|
1059
|
-
} else {
|
|
1060
|
-
const col = column;
|
|
1061
|
-
childProjectionItems.push({ alias, expr: createColumnRef(col.table, col.column) });
|
|
1062
|
-
}
|
|
1113
|
+
const expr = extractExpression(column);
|
|
1114
|
+
childProjectionItems.push({ alias, expr });
|
|
1063
1115
|
}
|
|
1064
1116
|
const includeAst = compact2({
|
|
1065
1117
|
kind: "includeMany",
|
|
@@ -1194,24 +1246,14 @@ function buildProjectionItems(projectionState, includesForMeta) {
|
|
|
1194
1246
|
expr: { kind: "includeRef", alias }
|
|
1195
1247
|
});
|
|
1196
1248
|
} else {
|
|
1197
|
-
const
|
|
1198
|
-
if (
|
|
1199
|
-
|
|
1200
|
-
alias,
|
|
1201
|
-
expr: operationExpr
|
|
1202
|
-
});
|
|
1203
|
-
} else {
|
|
1204
|
-
const col = column;
|
|
1205
|
-
const tableName = col.table;
|
|
1206
|
-
const columnName = col.column;
|
|
1207
|
-
if (!tableName || !columnName) {
|
|
1208
|
-
errorInvalidColumn(alias, i);
|
|
1209
|
-
}
|
|
1210
|
-
projectEntries.push({
|
|
1211
|
-
alias,
|
|
1212
|
-
expr: createColumnRef(tableName, columnName)
|
|
1213
|
-
});
|
|
1249
|
+
const expr = extractExpression(column);
|
|
1250
|
+
if (expr.kind === "col" && (!expr.table || !expr.column)) {
|
|
1251
|
+
errorInvalidColumn(alias, i);
|
|
1214
1252
|
}
|
|
1253
|
+
projectEntries.push({
|
|
1254
|
+
alias,
|
|
1255
|
+
expr
|
|
1256
|
+
});
|
|
1215
1257
|
}
|
|
1216
1258
|
}
|
|
1217
1259
|
return projectEntries;
|
|
@@ -1716,4 +1758,4 @@ export {
|
|
|
1716
1758
|
OrmModelBuilderImpl,
|
|
1717
1759
|
orm
|
|
1718
1760
|
};
|
|
1719
|
-
//# sourceMappingURL=chunk-
|
|
1761
|
+
//# sourceMappingURL=chunk-AIYGMPVJ.js.map
|