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.js
CHANGED
|
@@ -6311,6 +6311,31 @@ function normalizeArgsForDialect(dialect, args) {
|
|
|
6311
6311
|
if (dialect !== "postgres") return args;
|
|
6312
6312
|
return applyPostgresDistinctOrderBy(args);
|
|
6313
6313
|
}
|
|
6314
|
+
function normalizeCompoundCursor(cursor, model) {
|
|
6315
|
+
const keys = Object.keys(cursor);
|
|
6316
|
+
if (keys.length !== 1) return cursor;
|
|
6317
|
+
const key = keys[0];
|
|
6318
|
+
const value = cursor[key];
|
|
6319
|
+
const scalarSet = getScalarFieldSet(model);
|
|
6320
|
+
if (scalarSet.has(key)) return cursor;
|
|
6321
|
+
if (!isPlainObject(value)) return cursor;
|
|
6322
|
+
const nested = value;
|
|
6323
|
+
const nestedKeys = Object.keys(nested);
|
|
6324
|
+
if (nestedKeys.length === 0) return cursor;
|
|
6325
|
+
for (const nk of nestedKeys) {
|
|
6326
|
+
if (!scalarSet.has(nk)) return cursor;
|
|
6327
|
+
}
|
|
6328
|
+
return nested;
|
|
6329
|
+
}
|
|
6330
|
+
function normalizeArgsCompoundCursor(args, model) {
|
|
6331
|
+
if (!isNotNullish(args.cursor) || !isPlainObject(args.cursor)) return args;
|
|
6332
|
+
const flat = normalizeCompoundCursor(
|
|
6333
|
+
args.cursor,
|
|
6334
|
+
model
|
|
6335
|
+
);
|
|
6336
|
+
if (flat === args.cursor) return args;
|
|
6337
|
+
return __spreadProps(__spreadValues({}, args), { cursor: flat });
|
|
6338
|
+
}
|
|
6314
6339
|
function buildCursorClauseIfAny(input) {
|
|
6315
6340
|
const { cursor, orderBy, tableName, alias, params, skip, dialect, model } = input;
|
|
6316
6341
|
if (!isNotNullish(cursor)) return {};
|
|
@@ -6408,7 +6433,8 @@ function buildSelectSql(input) {
|
|
|
6408
6433
|
assertSafeTableRef(from.tableName);
|
|
6409
6434
|
const dialectToUse = resolveDialect(dialect);
|
|
6410
6435
|
const argsForSql = normalizeArgsForNegativeTake(method, args);
|
|
6411
|
-
const
|
|
6436
|
+
const argsWithDialect = normalizeArgsForDialect(dialectToUse, argsForSql);
|
|
6437
|
+
const normalizedArgs = normalizeArgsCompoundCursor(argsWithDialect, model);
|
|
6412
6438
|
validateDistinct(model, normalizedArgs.distinct);
|
|
6413
6439
|
validateOrderBy(model, normalizedArgs.orderBy);
|
|
6414
6440
|
validateCursor(model, normalizedArgs.cursor, normalizedArgs.distinct);
|