prisma-sql 1.72.0 → 1.74.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 +15 -7
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +15 -7
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +14 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- 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.74.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",
|
|
@@ -6880,12 +6880,12 @@ function resolveCountSelect(countSelectRaw, model) {
|
|
|
6880
6880
|
return null;
|
|
6881
6881
|
}
|
|
6882
6882
|
function buildIncludeColumns(spec) {
|
|
6883
|
-
var _a3, _b;
|
|
6883
|
+
var _a3, _b, _c, _d, _e;
|
|
6884
6884
|
const { select: select2, includes, dialect, model, schemas, from, params } = spec;
|
|
6885
6885
|
const baseSelect = (select2 != null ? select2 : "").trim();
|
|
6886
6886
|
let countCols = "";
|
|
6887
6887
|
let countJoins = [];
|
|
6888
|
-
const countSelectRaw = (_b = (_a3 = spec.args) == null ? void 0 : _a3.select) == null ? void 0 : _b[COUNT_SELECT_KEY];
|
|
6888
|
+
const countSelectRaw = (_e = (_b = (_a3 = spec.args) == null ? void 0 : _a3.select) == null ? void 0 : _b[COUNT_SELECT_KEY]) != null ? _e : (_d = (_c = spec.args) == null ? void 0 : _c.include) == null ? void 0 : _d[COUNT_SELECT_KEY];
|
|
6889
6889
|
if (countSelectRaw) {
|
|
6890
6890
|
const resolvedCountSelect = resolveCountSelect(countSelectRaw, model);
|
|
6891
6891
|
if (resolvedCountSelect && Object.keys(resolvedCountSelect).length > 0) {
|
|
@@ -7020,7 +7020,7 @@ function extractIncludeSpec(args) {
|
|
|
7020
7020
|
const includeSpec = {};
|
|
7021
7021
|
if (args.include && isPlainObject(args.include)) {
|
|
7022
7022
|
for (const [key, value] of Object.entries(args.include)) {
|
|
7023
|
-
if (value !== false) {
|
|
7023
|
+
if (value !== false && key !== COUNT_SELECT_KEY) {
|
|
7024
7024
|
includeSpec[key] = value;
|
|
7025
7025
|
}
|
|
7026
7026
|
}
|
|
@@ -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);
|