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/index.js
CHANGED
|
@@ -5149,14 +5149,18 @@ function buildNestedToOneJoins(relations, baseAlias, baseModel, aliasGen, dialec
|
|
|
5149
5149
|
}
|
|
5150
5150
|
return { joins, aliasMap };
|
|
5151
5151
|
}
|
|
5152
|
-
function buildNestedToOneSelects(relations, aliasMap) {
|
|
5152
|
+
function buildNestedToOneSelects(relations, aliasMap, dialect) {
|
|
5153
5153
|
const selects = [];
|
|
5154
5154
|
for (const rel of relations) {
|
|
5155
5155
|
const relAlias = aliasMap.get(rel.name);
|
|
5156
5156
|
if (!relAlias) continue;
|
|
5157
5157
|
const relSelect = buildRelationSelect(rel.args, rel.model, relAlias);
|
|
5158
5158
|
if (!relSelect || relSelect.trim().length === 0) continue;
|
|
5159
|
-
|
|
5159
|
+
const jsonExpr = jsonBuildObject(relSelect, dialect);
|
|
5160
|
+
const pkField = getPrimaryKeyField(rel.model);
|
|
5161
|
+
const pkCol = `${relAlias}.${quoteColumn(rel.model, pkField)}`;
|
|
5162
|
+
const nullSafeExpr = `CASE WHEN ${pkCol} IS NOT NULL THEN ${jsonExpr} ELSE NULL END`;
|
|
5163
|
+
selects.push(`${sqlStringLiteral(rel.name)}, ${nullSafeExpr}`);
|
|
5160
5164
|
}
|
|
5161
5165
|
return selects;
|
|
5162
5166
|
}
|
|
@@ -5234,7 +5238,11 @@ function buildSelectWithNestedIncludes(relArgs, relModel, relAlias, ctx) {
|
|
|
5234
5238
|
ctx.dialect
|
|
5235
5239
|
);
|
|
5236
5240
|
const baseSelect = buildRelationSelect(relArgs, relModel, relAlias);
|
|
5237
|
-
const nestedSelects = buildNestedToOneSelects(
|
|
5241
|
+
const nestedSelects = buildNestedToOneSelects(
|
|
5242
|
+
nestedToOnes,
|
|
5243
|
+
aliasMap,
|
|
5244
|
+
ctx.dialect
|
|
5245
|
+
);
|
|
5238
5246
|
const allParts = [];
|
|
5239
5247
|
if (baseSelect && baseSelect.trim().length > 0) {
|
|
5240
5248
|
allParts.push(baseSelect);
|