@prisma/orm-family-sql 8.0.0-rc.11-dev.46 → 8.0.0-rc.11-dev.48

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.
Files changed (34) hide show
  1. package/dist/contract-prisma7__provider.mjs +24 -10
  2. package/dist/contract-prisma7__provider.mjs.map +1 -1
  3. package/dist/contract-psl.d.mts +1 -1
  4. package/dist/contract-psl.d.mts.map +1 -1
  5. package/dist/contract-psl.mjs +1 -1
  6. package/dist/contract-psl__attribute-specs.d.mts +1 -1
  7. package/dist/contract-psl__attribute-specs.d.mts.map +1 -1
  8. package/dist/contract-psl__attribute-specs.mjs +1 -1
  9. package/dist/contract-psl__provider.mjs +1 -1
  10. package/dist/contract-psl__provider.mjs.map +1 -1
  11. package/dist/{control-FOipY3kl.mjs → control-CHDnLhfP.mjs} +2 -2
  12. package/dist/{control-FOipY3kl.mjs.map → control-CHDnLhfP.mjs.map} +1 -1
  13. package/dist/{control-DZ6oxNo3.d.mts → control-DIh8VSPj.d.mts} +2 -2
  14. package/dist/{control-DZ6oxNo3.d.mts.map → control-DIh8VSPj.d.mts.map} +1 -1
  15. package/dist/family.d.mts +2 -2
  16. package/dist/family.mjs +2 -2
  17. package/dist/family__control.d.mts +1 -1
  18. package/dist/family__control.mjs +1 -1
  19. package/dist/family__pack.mjs +1 -1
  20. package/dist/family__psl-infer.d.mts +1 -1
  21. package/dist/family__psl-infer.mjs +1 -1
  22. package/dist/{interpreter-BIBwrA2w-DAiNN30m.mjs → interpreter-BcaXUphN-CplfU9YE.mjs} +3 -33
  23. package/dist/interpreter-BcaXUphN-CplfU9YE.mjs.map +1 -0
  24. package/dist/{psl-infer-BAbdN_ZR.mjs → psl-infer-Csug77mi.mjs} +15 -6
  25. package/dist/psl-infer-Csug77mi.mjs.map +1 -0
  26. package/dist/{psl-infer-DQCWvJtk.d.mts → psl-infer-CuTqC9UV.d.mts} +6 -5
  27. package/dist/psl-infer-CuTqC9UV.d.mts.map +1 -0
  28. package/dist/{sql-attribute-specs-BH0U6i1B-Ces5ZCvv.mjs → sql-attribute-specs-BjCzXYcO-Cj8SS3iE.mjs} +50 -4
  29. package/dist/sql-attribute-specs-BjCzXYcO-Cj8SS3iE.mjs.map +1 -0
  30. package/package.json +18 -18
  31. package/dist/interpreter-BIBwrA2w-DAiNN30m.mjs.map +0 -1
  32. package/dist/psl-infer-BAbdN_ZR.mjs.map +0 -1
  33. package/dist/psl-infer-DQCWvJtk.d.mts.map +0 -1
  34. package/dist/sql-attribute-specs-BH0U6i1B-Ces5ZCvv.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { d as validateSqlStorageConsistency, l as validateModelStorageReferences } from "./validators-y6eLjhcb.mjs";
2
2
  import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
3
3
  import { n as buildSqlContractFromDefinition, t as applySqlSpecifierControlPolicy } from "./derived-checks-6WZKIUxH-B3Pd6QA5.mjs";
4
- import { c as resolveFieldTypeDescriptor, i as indexFkRelations, n as buildEntityTypesByDiscriminator, o as normalizeReferentialAction, r as entryForTag, s as readDataTypeDefault, t as applyBackrelationCandidates } from "./interpreter-BIBwrA2w-DAiNN30m.mjs";
4
+ import { c as resolveFieldTypeDescriptor, i as indexFkRelations, n as buildEntityTypesByDiscriminator, o as normalizeReferentialAction, r as entryForTag, s as readDataTypeDefault, t as applyBackrelationCandidates } from "./interpreter-BcaXUphN-CplfU9YE.mjs";
5
5
  import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
6
6
  import { collectScalarTypeConstructors, instantiateAuthoringEntityType } from "@prisma/orm-framework/components/authoring";
7
7
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
@@ -56,7 +56,6 @@ const FUNCTION_ARGUMENT_KEYS = {
56
56
  uuid: ["version"],
57
57
  cuid: ["version"],
58
58
  nanoid: ["size"],
59
- dbgenerated: ["expression"],
60
59
  now: [],
61
60
  autoincrement: [],
62
61
  ulid: []
@@ -244,14 +243,7 @@ function lowerFunction(call, input, label, unknown) {
244
243
  const fn = call.path().join(".");
245
244
  const span = input.attribute.span;
246
245
  const callArgs = [...call.args()];
247
- if (fn === "dbgenerated" && callArgs.length === 0) {
248
- if (input.field.optional || input.field.list) return {
249
- storage: void 0,
250
- onCreate: void 0
251
- };
252
- input.diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_UNKNOWN_DEFAULT", `${label}: @default(dbgenerated()) with no expression is not supported yet on a required field, because without a column default Prisma 8 requires the value on create. Either remove the @default, which makes Prisma 7's next migration drop the column default (ALTER COLUMN ... DROP DEFAULT) and both clients require the value on create, or write the column's database default as @default(dbgenerated("<expression>")), which Prisma 7's next migration sets on the column.`, input.sourceId, span));
253
- return;
254
- }
246
+ if (fn === "dbgenerated") return dbgeneratedDefault(callArgs, unknown, span);
255
247
  const keys = FUNCTION_ARGUMENT_KEYS[fn];
256
248
  const entry = input.controlMutationDefaults.defaultFunctionRegistry.get(fn);
257
249
  if (keys === void 0 || entry === void 0) return unknown(`function "${fn}()" is not a Prisma 7 default function this target supports.`, span);
@@ -291,6 +283,28 @@ function lowerFunction(call, input, label, unknown) {
291
283
  onCreate: lowered.value.generated
292
284
  };
293
285
  }
286
+ /**
287
+ * Prisma 7's `dbgenerated("<sql>")` is a raw SQL default, carried as written; the empty form
288
+ * `dbgenerated()` means the column has no default. Prisma 7 refuses a blank string, so this
289
+ * source does too.
290
+ */
291
+ function dbgeneratedDefault(callArgs, unknown, span) {
292
+ if (callArgs.length === 0) return {
293
+ storage: void 0,
294
+ onCreate: void 0
295
+ };
296
+ const [argument] = callArgs;
297
+ const value = argument?.value();
298
+ const expression = callArgs.length === 1 && argument?.name() === void 0 && value !== void 0 ? StringLiteralExprAst.cast(value.syntax)?.value() : void 0;
299
+ if (expression === void 0 || expression.trim() === "") return unknown("function \"dbgenerated()\" has an argument this contract source does not read.", span);
300
+ return {
301
+ storage: {
302
+ kind: "function",
303
+ expression
304
+ },
305
+ onCreate: void 0
306
+ };
307
+ }
294
308
  function parseIndexAttribute(attribute, owner, sourceId, indexTypes, diagnostics) {
295
309
  const unsupported = (what, span) => {
296
310
  diagnostics.push(prisma7Diagnostic("PSL.PRISMA7_INDEX_ARGUMENT_UNSUPPORTED", `"${owner}": @${attribute.name} ${what}`, sourceId, span));