prisma-sql 1.76.2 → 1.78.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 +61 -4
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +61 -4
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +38 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +59 -76
package/dist/index.cjs
CHANGED
|
@@ -6313,6 +6313,31 @@ function normalizeArgsForDialect(dialect, args) {
|
|
|
6313
6313
|
if (dialect !== "postgres") return args;
|
|
6314
6314
|
return applyPostgresDistinctOrderBy(args);
|
|
6315
6315
|
}
|
|
6316
|
+
function normalizeCompoundCursor(cursor, model) {
|
|
6317
|
+
const keys = Object.keys(cursor);
|
|
6318
|
+
if (keys.length !== 1) return cursor;
|
|
6319
|
+
const key = keys[0];
|
|
6320
|
+
const value = cursor[key];
|
|
6321
|
+
const scalarSet = getScalarFieldSet(model);
|
|
6322
|
+
if (scalarSet.has(key)) return cursor;
|
|
6323
|
+
if (!isPlainObject(value)) return cursor;
|
|
6324
|
+
const nested = value;
|
|
6325
|
+
const nestedKeys = Object.keys(nested);
|
|
6326
|
+
if (nestedKeys.length === 0) return cursor;
|
|
6327
|
+
for (const nk of nestedKeys) {
|
|
6328
|
+
if (!scalarSet.has(nk)) return cursor;
|
|
6329
|
+
}
|
|
6330
|
+
return nested;
|
|
6331
|
+
}
|
|
6332
|
+
function normalizeArgsCompoundCursor(args, model) {
|
|
6333
|
+
if (!isNotNullish(args.cursor) || !isPlainObject(args.cursor)) return args;
|
|
6334
|
+
const flat = normalizeCompoundCursor(
|
|
6335
|
+
args.cursor,
|
|
6336
|
+
model
|
|
6337
|
+
);
|
|
6338
|
+
if (flat === args.cursor) return args;
|
|
6339
|
+
return __spreadProps(__spreadValues({}, args), { cursor: flat });
|
|
6340
|
+
}
|
|
6316
6341
|
function buildCursorClauseIfAny(input) {
|
|
6317
6342
|
const { cursor, orderBy, tableName, alias, params, skip, dialect, model } = input;
|
|
6318
6343
|
if (!isNotNullish(cursor)) return {};
|
|
@@ -6410,7 +6435,8 @@ function buildSelectSql(input) {
|
|
|
6410
6435
|
assertSafeTableRef(from.tableName);
|
|
6411
6436
|
const dialectToUse = resolveDialect(dialect);
|
|
6412
6437
|
const argsForSql = normalizeArgsForNegativeTake(method, args);
|
|
6413
|
-
const
|
|
6438
|
+
const argsWithDialect = normalizeArgsForDialect(dialectToUse, argsForSql);
|
|
6439
|
+
const normalizedArgs = normalizeArgsCompoundCursor(argsWithDialect, model);
|
|
6414
6440
|
validateDistinct(model, normalizedArgs.distinct);
|
|
6415
6441
|
validateOrderBy(model, normalizedArgs.orderBy);
|
|
6416
6442
|
validateCursor(model, normalizedArgs.cursor, normalizedArgs.distinct);
|
|
@@ -8075,6 +8101,14 @@ function buildKey(row, fields) {
|
|
|
8075
8101
|
}
|
|
8076
8102
|
|
|
8077
8103
|
// src/builder/select/reducer.ts
|
|
8104
|
+
var UNSAFE_PROPERTY_NAMES = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
8105
|
+
function assertSafePropertyName(name) {
|
|
8106
|
+
if (UNSAFE_PROPERTY_NAMES.has(name)) {
|
|
8107
|
+
throw new Error(
|
|
8108
|
+
`Unsafe property name '${name}' rejected to prevent prototype pollution`
|
|
8109
|
+
);
|
|
8110
|
+
}
|
|
8111
|
+
}
|
|
8078
8112
|
function buildRelationScalarCols(relModel, relPath, includeAllScalars, selectedScalarFields) {
|
|
8079
8113
|
const jsonSet = getJsonFieldSet(relModel);
|
|
8080
8114
|
const scalarFields = includeAllScalars ? getScalarFieldNames(relModel) : selectedScalarFields;
|
|
@@ -8106,6 +8140,7 @@ function buildReducerConfig(parentModel, includeSpec, allModels, prefix = "", de
|
|
|
8106
8140
|
const modelMap = new Map(allModels.map((m) => [m.name, m]));
|
|
8107
8141
|
for (const [incName, incValue] of Object.entries(includeSpec)) {
|
|
8108
8142
|
if (incValue === false) continue;
|
|
8143
|
+
assertSafePropertyName(incName);
|
|
8109
8144
|
const field = parentModel.fields.find((f) => f.name === incName);
|
|
8110
8145
|
if (!field || !field.isRelation) {
|
|
8111
8146
|
throw new Error(
|
|
@@ -8183,7 +8218,7 @@ function initNestedPlaceholders(obj, nested) {
|
|
|
8183
8218
|
function materializeRelationObject(row, rel) {
|
|
8184
8219
|
const relKey = buildKey(row, rel.keyCols);
|
|
8185
8220
|
if (relKey == null) return null;
|
|
8186
|
-
const obj =
|
|
8221
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
8187
8222
|
for (const c of rel.scalarCols) {
|
|
8188
8223
|
obj[c.fieldName] = parseJsonIfNeeded(c.isJson, row[c.colName]);
|
|
8189
8224
|
}
|
|
@@ -8251,7 +8286,7 @@ function reduceFlatRows(rows, config) {
|
|
|
8251
8286
|
if (parentKey == null) continue;
|
|
8252
8287
|
let record = resultMap.get(parentKey);
|
|
8253
8288
|
if (!record) {
|
|
8254
|
-
record =
|
|
8289
|
+
record = /* @__PURE__ */ Object.create(null);
|
|
8255
8290
|
for (const fieldName of parentScalarFields) {
|
|
8256
8291
|
record[fieldName] = maybeParseJson(
|
|
8257
8292
|
row[fieldName],
|