prisma-sql 1.72.0 → 1.73.0
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/generator.cjs +12 -4
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +12 -4
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/generator.js
CHANGED
|
@@ -2312,7 +2312,7 @@ var require_package = __commonJS({
|
|
|
2312
2312
|
"package.json"(exports$1, module) {
|
|
2313
2313
|
module.exports = {
|
|
2314
2314
|
name: "prisma-sql",
|
|
2315
|
-
version: "1.
|
|
2315
|
+
version: "1.73.0",
|
|
2316
2316
|
description: "Convert Prisma queries to optimized SQL with type safety. 2-7x faster than Prisma Client.",
|
|
2317
2317
|
main: "dist/index.cjs",
|
|
2318
2318
|
module: "dist/index.js",
|
|
@@ -7428,14 +7428,18 @@ function buildNestedToOneJoins(relations, baseAlias, baseModel, aliasGen, dialec
|
|
|
7428
7428
|
}
|
|
7429
7429
|
return { joins, aliasMap };
|
|
7430
7430
|
}
|
|
7431
|
-
function buildNestedToOneSelects(relations, aliasMap) {
|
|
7431
|
+
function buildNestedToOneSelects(relations, aliasMap, dialect) {
|
|
7432
7432
|
const selects = [];
|
|
7433
7433
|
for (const rel of relations) {
|
|
7434
7434
|
const relAlias = aliasMap.get(rel.name);
|
|
7435
7435
|
if (!relAlias) continue;
|
|
7436
7436
|
const relSelect = buildRelationSelect(rel.args, rel.model, relAlias);
|
|
7437
7437
|
if (!relSelect || relSelect.trim().length === 0) continue;
|
|
7438
|
-
|
|
7438
|
+
const jsonExpr = jsonBuildObject(relSelect, dialect);
|
|
7439
|
+
const pkField = getPrimaryKeyField(rel.model);
|
|
7440
|
+
const pkCol = `${relAlias}.${quoteColumn(rel.model, pkField)}`;
|
|
7441
|
+
const nullSafeExpr = `CASE WHEN ${pkCol} IS NOT NULL THEN ${jsonExpr} ELSE NULL END`;
|
|
7442
|
+
selects.push(`${sqlStringLiteral(rel.name)}, ${nullSafeExpr}`);
|
|
7439
7443
|
}
|
|
7440
7444
|
return selects;
|
|
7441
7445
|
}
|
|
@@ -7513,7 +7517,11 @@ function buildSelectWithNestedIncludes(relArgs, relModel, relAlias, ctx) {
|
|
|
7513
7517
|
ctx.dialect
|
|
7514
7518
|
);
|
|
7515
7519
|
const baseSelect = buildRelationSelect(relArgs, relModel, relAlias);
|
|
7516
|
-
const nestedSelects = buildNestedToOneSelects(
|
|
7520
|
+
const nestedSelects = buildNestedToOneSelects(
|
|
7521
|
+
nestedToOnes,
|
|
7522
|
+
aliasMap,
|
|
7523
|
+
ctx.dialect
|
|
7524
|
+
);
|
|
7517
7525
|
const allParts = [];
|
|
7518
7526
|
if (baseSelect && baseSelect.trim().length > 0) {
|
|
7519
7527
|
allParts.push(baseSelect);
|