joist-core 2.3.0-next.103 → 2.3.0-next.104
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/build/queries/sql/expressions/types.d.cts +1 -1
- package/build/queries/sql/expressions/types.d.cts.map +1 -1
- package/build/queries/sql/expressions/types.d.mts +1 -1
- package/build/queries/sql/expressions/types.d.mts.map +1 -1
- package/build/queries/sql/query.cjs +12 -10
- package/build/queries/sql/query.cjs.map +1 -1
- package/build/queries/sql/query.d.cts +28 -10
- package/build/queries/sql/query.d.cts.map +1 -1
- package/build/queries/sql/query.d.mts +28 -10
- package/build/queries/sql/query.d.mts.map +1 -1
- package/build/queries/sql/query.js +12 -10
- package/build/queries/sql/query.js.map +1 -1
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@ type ExprFromInput<I> = Expr<InputResult<I, []>, ExpressionSources<I>> & {
|
|
|
27
27
|
readonly [inputBrand]: I;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Computes the
|
|
30
|
+
* Computes the SQL expression type, including null from LEFT joins.
|
|
31
31
|
* I.e. Book.title is string | null when Book is LEFT-joined; COALESCE(Book.title, "Unknown") is string.
|
|
32
32
|
*/
|
|
33
33
|
type ExpressionValue<V, J extends QueryJoinList> = unknown extends V ? V : V extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../../src/queries/sql/expressions/types.ts"],"mappings":";;;;;;;;;;UAcU;EACR,MAAM;EACN,UAAU;EACV,UAAU;EACV,QAAQ;EACR,UAAU;EACV,OAAO;;KAIG,WAAW,cAAc;KAChC,mBAAmB,KAAK,uBAAuB,KAAK,6BAA2B;KAC/E,SAAS,KAAK,QAAQ,QAAQ,IAAI;;KAG3B,eACT,WAAW,aAAa,WAAW,iBAAiB,KAAK,cAAc,qBAAqB,wBACvF;cAEM;;KAGF,cAAc,KAAK,KAAK,YAAY,QAAQ,kBAAkB;YAC9D,aAA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AK;WAAqB;IAC5C,UAAU,wCAEI,WAAW,IAAI,oBACrB,gBAAgB,EAAE,IAAI,KACtB,gBAAgB,4BACd,EAAE,wBAIZ,gBAAgB,GAAG"}
|
|
@@ -27,7 +27,7 @@ type ExprFromInput<I> = Expr<InputResult<I, []>, ExpressionSources<I>> & {
|
|
|
27
27
|
readonly [inputBrand]: I;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Computes the
|
|
30
|
+
* Computes the SQL expression type, including null from LEFT joins.
|
|
31
31
|
* I.e. Book.title is string | null when Book is LEFT-joined; COALESCE(Book.title, "Unknown") is string.
|
|
32
32
|
*/
|
|
33
33
|
type ExpressionValue<V, J extends QueryJoinList> = unknown extends V ? V : V extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/queries/sql/expressions/types.ts"],"mappings":";;;;;;;;;;UAcU;EACR,MAAM;EACN,UAAU;EACV,UAAU;EACV,QAAQ;EACR,UAAU;EACV,OAAO;;KAIG,WAAW,cAAc;KAChC,mBAAmB,KAAK,uBAAuB,KAAK,6BAA2B;KAC/E,SAAS,KAAK,QAAQ,QAAQ,IAAI;;KAG3B,eACT,WAAW,aAAa,WAAW,iBAAiB,KAAK,cAAc,qBAAqB,wBACvF;cAEM;;KAGF,cAAc,KAAK,KAAK,YAAY,QAAQ,kBAAkB;YAC9D,aAAa;;;;;;KAOb,gBAAgB,GAAG,UAAU,iCAAiC,
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/queries/sql/expressions/types.ts"],"mappings":";;;;;;;;;;UAcU;EACR,MAAM;EACN,UAAU;EACV,UAAU;EACV,QAAQ;EACR,UAAU;EACV,OAAO;;KAIG,WAAW,cAAc;KAChC,mBAAmB,KAAK,uBAAuB,KAAK,6BAA2B;KAC/E,SAAS,KAAK,QAAQ,QAAQ,IAAI;;KAG3B,eACT,WAAW,aAAa,WAAW,iBAAiB,KAAK,cAAc,qB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cAC3B;WAAqB,YAAY;IAC/B,kBAAkB,aAAa;;;;;;KAQtC,iBAAiB,GAAG,MAAM,oBAC7B,oBACI,sBACE,gBAAgB,gBAAgB,QAAQ,gBAAgB;;KAQpD,gBAAgB,GAAG,KAC7B,UAAU,8BAEN;WAAqB,gBAAgB;;WACxB,UAAU,cAAc,GAAG,0BAA0B,OAAO;gBAC3D,KAAK,cAAc,4BAE/B,UAAU,gBACR,UAAU,wBAEI,WAAW,IAAI,UAAU,WAC/B,EAAE,gCACA,cAAc,EAAE,IAAI,GAAG,gCAKjC;WAAqB,YAAY;;WACpB,MAAM,UAAU,GAAG;IAAO,iBAAiB,aAAa,kBACrD,KAAK,cAAc,wBAEjC,yDAEG,+BAEC,2BAEE,WAAW,+BAA+B,SAAS,KAAK;;KAKrE,cAAc,8BAA8B,aAAa,UAAU,MAAM,uCAC3D,wBAEb,sFAGF,2BACK,UAAU,0DACU,WAAW,IAAI,gBAAgB,EAAE,IAAI,QAAO,iBAAiB;;KAG9E,WAAW,MAAM,YAAY,gBAAgB,GAAG,QAAQ,aAAa,wBAE7E,gBAAgB,GAAG,QAAQ,aAAa;;;;;;KAOhC,mBACR,WACA,0BACA,2BACA,2BACA,yBACA,2BACA,wBACA;;UAGa;EACf;EACA;;;KAIU,cAAc,KAAK;;KAG1B,cAAc,KAAK;WAAqB,aAAa;IAAM,IAAI;;KAG/D,cAAc,GAAG,KAAK;WAAqB;IAC5C,UAAU,wCAEI,WAAW,IAAI,oBACrB,gBAAgB,EAAE,IAAI,KACtB,gBAAgB,4BACd,EAAE,wBAIZ,gBAAgB,GAAG"}
|
|
@@ -29,7 +29,7 @@ const require_queries_sql_JoinTree = require("./JoinTree.cjs");
|
|
|
29
29
|
* select: { name: a.first_name, n: bookStats.n },
|
|
30
30
|
* orderBy: { n: "DESC" },
|
|
31
31
|
* });
|
|
32
|
-
* // rows: { name: string; n: number |
|
|
32
|
+
* // rows: { name: string; n: number | undefined }[] (undefined because of the LEFT join)
|
|
33
33
|
*
|
|
34
34
|
* `em.query(pojo)` runs it. `select` decides the row type: a bare table returns entities, a
|
|
35
35
|
* `{ key: expr }` object returns typed POJOs, a bare subquery returns that subquery's rows.
|
|
@@ -188,8 +188,8 @@ function isReadQueryValue(arg) {
|
|
|
188
188
|
* Compiles scalar or nonempty named expression projections, shared by SELECT and mutation RETURNING.
|
|
189
189
|
* Source-shaped values need read hydration/source rules and are deliberately excluded here.
|
|
190
190
|
*/
|
|
191
|
-
function projectionToSql(select, ctx) {
|
|
192
|
-
const output = projectionOutput(select);
|
|
191
|
+
function projectionToSql(select, ctx, joins) {
|
|
192
|
+
const output = joinedOutput(projectionOutput(select), joins);
|
|
193
193
|
if (output.kind === "scalar") {
|
|
194
194
|
const expr = output.columns[0][1];
|
|
195
195
|
const fragment = expr.toSql(ctx);
|
|
@@ -198,7 +198,7 @@ function projectionToSql(select, ctx) {
|
|
|
198
198
|
...fragment,
|
|
199
199
|
sql: `${fragment.sql} AS value`
|
|
200
200
|
}],
|
|
201
|
-
decodeRows: (_, rows) => rows.map((row) => expr
|
|
201
|
+
decodeRows: (_, rows) => rows.map((row) => decodeValue(expr, row.value)),
|
|
202
202
|
output
|
|
203
203
|
};
|
|
204
204
|
}
|
|
@@ -530,7 +530,7 @@ function projectionOutput(select) {
|
|
|
530
530
|
return require_utils.fail("Expected a scalar expression or a nonempty named expression projection");
|
|
531
531
|
}
|
|
532
532
|
/**
|
|
533
|
-
* Adds
|
|
533
|
+
* Adds SQL nullability from unmatched LEFT joins without mutating shared expressions or their codecs.
|
|
534
534
|
* Only direct columns carry sqlSource; COUNT and COALESCE retain their own SQL nullability.
|
|
535
535
|
* I.e. selecting Book.title from a LEFT-joined Book makes its output nullable, but COUNT(Book.id) stays NOT NULL.
|
|
536
536
|
*/
|
|
@@ -638,7 +638,7 @@ function parseSetQuery(q, parent, assigner, recursiveSelf) {
|
|
|
638
638
|
bindings,
|
|
639
639
|
outerRefs: [...new Set(outerRefs.filter((ref) => !cteAliases.has(ref)))],
|
|
640
640
|
output,
|
|
641
|
-
decodeRows:
|
|
641
|
+
decodeRows: (_, rows) => rows.map((row) => decodeRow(row, output.columns))
|
|
642
642
|
};
|
|
643
643
|
}
|
|
644
644
|
/** Validate and quote only named set output sorts, including before a reusable value is parsed. */
|
|
@@ -1030,9 +1030,7 @@ function selectsToSql(q, ctx, from, entitySelects) {
|
|
|
1030
1030
|
output
|
|
1031
1031
|
};
|
|
1032
1032
|
}
|
|
1033
|
-
|
|
1034
|
-
projection.output = joinedOutput(projection.output, q.join);
|
|
1035
|
-
return projection;
|
|
1033
|
+
return projectionToSql(select, ctx, q.join);
|
|
1036
1034
|
}
|
|
1037
1035
|
/**
|
|
1038
1036
|
* Builds the mandatory CTI joins and flat row projection needed by entity hydration.
|
|
@@ -1171,7 +1169,7 @@ function decodeRow(row, decoders) {
|
|
|
1171
1169
|
const result = {};
|
|
1172
1170
|
for (const [key, expr] of decoders) {
|
|
1173
1171
|
const value = row[key];
|
|
1174
|
-
const decoded =
|
|
1172
|
+
const decoded = decodeValue(expr, value);
|
|
1175
1173
|
if (key === "__proto__") Object.defineProperty(result, key, {
|
|
1176
1174
|
value: decoded,
|
|
1177
1175
|
enumerable: true,
|
|
@@ -1182,6 +1180,10 @@ function decodeRow(row, decoders) {
|
|
|
1182
1180
|
}
|
|
1183
1181
|
return result;
|
|
1184
1182
|
}
|
|
1183
|
+
/** Decodes a top-level projected SQL NULL using Joist's undefined convention. */
|
|
1184
|
+
function decodeValue(expr, value) {
|
|
1185
|
+
return value === null ? void 0 : expr.decode(value);
|
|
1186
|
+
}
|
|
1185
1187
|
const ORDER_BY_DIRECTIONS = [
|
|
1186
1188
|
"ASC",
|
|
1187
1189
|
"DESC",
|