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.cjs
CHANGED
|
@@ -2323,7 +2323,7 @@ var require_package = __commonJS({
|
|
|
2323
2323
|
"package.json"(exports$1, module) {
|
|
2324
2324
|
module.exports = {
|
|
2325
2325
|
name: "prisma-sql",
|
|
2326
|
-
version: "1.
|
|
2326
|
+
version: "1.73.0",
|
|
2327
2327
|
description: "Convert Prisma queries to optimized SQL with type safety. 2-7x faster than Prisma Client.",
|
|
2328
2328
|
main: "dist/index.cjs",
|
|
2329
2329
|
module: "dist/index.js",
|
|
@@ -7439,14 +7439,18 @@ function buildNestedToOneJoins(relations, baseAlias, baseModel, aliasGen, dialec
|
|
|
7439
7439
|
}
|
|
7440
7440
|
return { joins, aliasMap };
|
|
7441
7441
|
}
|
|
7442
|
-
function buildNestedToOneSelects(relations, aliasMap) {
|
|
7442
|
+
function buildNestedToOneSelects(relations, aliasMap, dialect) {
|
|
7443
7443
|
const selects = [];
|
|
7444
7444
|
for (const rel of relations) {
|
|
7445
7445
|
const relAlias = aliasMap.get(rel.name);
|
|
7446
7446
|
if (!relAlias) continue;
|
|
7447
7447
|
const relSelect = buildRelationSelect(rel.args, rel.model, relAlias);
|
|
7448
7448
|
if (!relSelect || relSelect.trim().length === 0) continue;
|
|
7449
|
-
|
|
7449
|
+
const jsonExpr = jsonBuildObject(relSelect, dialect);
|
|
7450
|
+
const pkField = getPrimaryKeyField(rel.model);
|
|
7451
|
+
const pkCol = `${relAlias}.${quoteColumn(rel.model, pkField)}`;
|
|
7452
|
+
const nullSafeExpr = `CASE WHEN ${pkCol} IS NOT NULL THEN ${jsonExpr} ELSE NULL END`;
|
|
7453
|
+
selects.push(`${sqlStringLiteral(rel.name)}, ${nullSafeExpr}`);
|
|
7450
7454
|
}
|
|
7451
7455
|
return selects;
|
|
7452
7456
|
}
|
|
@@ -7524,7 +7528,11 @@ function buildSelectWithNestedIncludes(relArgs, relModel, relAlias, ctx) {
|
|
|
7524
7528
|
ctx.dialect
|
|
7525
7529
|
);
|
|
7526
7530
|
const baseSelect = buildRelationSelect(relArgs, relModel, relAlias);
|
|
7527
|
-
const nestedSelects = buildNestedToOneSelects(
|
|
7531
|
+
const nestedSelects = buildNestedToOneSelects(
|
|
7532
|
+
nestedToOnes,
|
|
7533
|
+
aliasMap,
|
|
7534
|
+
ctx.dialect
|
|
7535
|
+
);
|
|
7528
7536
|
const allParts = [];
|
|
7529
7537
|
if (baseSelect && baseSelect.trim().length > 0) {
|
|
7530
7538
|
allParts.push(baseSelect);
|