prisma-sql 1.77.0 → 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 +27 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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);
|