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