@prisma/orm-family-sql 8.0.0-rc.14-dev.1 → 8.0.0-rc.14-dev.2
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/{ast-DQU1yUQ5.d.mts → ast-B53rACdv.d.mts} +3 -3
- package/dist/{ast-DQU1yUQ5.d.mts.map → ast-B53rACdv.d.mts.map} +1 -1
- package/dist/{authoring-entity-types-CZ-vdwYS-GsYvzoFF.d.mts → authoring-entity-types-CZ-vdwYS-D6R9QovE.d.mts} +2 -2
- package/dist/{authoring-entity-types-CZ-vdwYS-GsYvzoFF.d.mts.map → authoring-entity-types-CZ-vdwYS-D6R9QovE.d.mts.map} +1 -1
- package/dist/{authoring-type-constructors-DQZEX4Sb-BYGQWq43.mjs → authoring-type-constructors-DQZEX4Sb-D6uFhwhG.mjs} +2 -2
- package/dist/{authoring-type-constructors-DQZEX4Sb-BYGQWq43.mjs.map → authoring-type-constructors-DQZEX4Sb-D6uFhwhG.mjs.map} +1 -1
- package/dist/builder.d.mts +2 -2
- package/dist/builder__runtime.d.mts +6 -6
- package/dist/builder__types.d.mts +2 -2
- package/dist/{config-types-B86lMw4s.mjs → config-types-CEXpi8FV.mjs} +2 -2
- package/dist/{config-types-B86lMw4s.mjs.map → config-types-CEXpi8FV.mjs.map} +1 -1
- package/dist/{contract-builder-j05FWfIe.d.mts → contract-builder-6ujqQuj-.d.mts} +2 -2
- package/dist/{contract-builder-j05FWfIe.d.mts.map → contract-builder-6ujqQuj-.d.mts.map} +1 -1
- package/dist/{contract-builder-Fw-SFRvK.mjs → contract-builder-vmb0E3SP.mjs} +2 -2
- package/dist/{contract-builder-Fw-SFRvK.mjs.map → contract-builder-vmb0E3SP.mjs.map} +1 -1
- package/dist/contract-emitter.mjs +1 -1
- package/dist/contract-prisma7__provider.mjs +4 -4
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.d.mts +4 -4
- package/dist/contract-psl.d.mts.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.d.mts +1 -1
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.d.mts +1 -1
- package/dist/contract-ts__contract-builder.mjs +2 -2
- package/dist/contract.d.mts +2 -1
- package/dist/contract.mjs +2 -1
- package/dist/contract__sql-expression.d.mts +2 -0
- package/dist/contract__sql-expression.mjs +2 -0
- package/dist/{control-DOGYQMFH.mjs → control-2-eFP31F.mjs} +9 -47
- package/dist/control-2-eFP31F.mjs.map +1 -0
- package/dist/{control-kbS8DWF0.d.mts → control-DmVQjyZd.d.mts} +15 -20
- package/dist/control-DmVQjyZd.d.mts.map +1 -0
- package/dist/{control-adapter-C99J7aEF-B571Jffd.d.mts → control-adapter-C99J7aEF-B3_IhgH6.d.mts} +4 -4
- package/dist/{control-adapter-C99J7aEF-B571Jffd.d.mts.map → control-adapter-C99J7aEF-B3_IhgH6.d.mts.map} +1 -1
- package/dist/control-adapter-kl-cOML5.d.mts +1 -0
- package/dist/{db-DLjWu9-f-CVAu8jgd.d.mts → db-DLjWu9-f-COdzEg7b.d.mts} +6 -6
- package/dist/{db-DLjWu9-f-CVAu8jgd.d.mts.map → db-DLjWu9-f-COdzEg7b.d.mts.map} +1 -1
- package/dist/{ddl-types-DD-i-Uj9-D99heD5Z.d.mts → ddl-types-DD-i-Uj9-BRqLNUDm.d.mts} +2 -2
- package/dist/{ddl-types-DD-i-Uj9-D99heD5Z.d.mts.map → ddl-types-DD-i-Uj9-BRqLNUDm.d.mts.map} +1 -1
- package/dist/{derived-checks-C6psACIj-DfqUVmZz.mjs → derived-checks-C6psACIj-BSBDa2_9.mjs} +3 -3
- package/dist/{derived-checks-C6psACIj-DfqUVmZz.mjs.map → derived-checks-C6psACIj-BSBDa2_9.mjs.map} +1 -1
- package/dist/{diff-BxwNI8yE.d.mts → diff-DFOiwUHg.d.mts} +3 -3
- package/dist/{diff-BxwNI8yE.d.mts.map → diff-DFOiwUHg.d.mts.map} +1 -1
- package/dist/{dist-U61NPKN3.mjs → dist-ChyuAdtP.mjs} +2 -2
- package/dist/{dist-U61NPKN3.mjs.map → dist-ChyuAdtP.mjs.map} +1 -1
- package/dist/{expression-BPoA5eEl.d.mts → expression-Dl5WvxCA.d.mts} +3 -3
- package/dist/{expression-BPoA5eEl.d.mts.map → expression-Dl5WvxCA.d.mts.map} +1 -1
- package/dist/family.d.mts +11 -11
- package/dist/family.mjs +3 -3
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +3 -3
- package/dist/family__control.mjs +2 -2
- package/dist/family__diff.d.mts +2 -2
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.mjs +1 -1
- package/dist/family__psl-build.d.mts +2 -2
- package/dist/family__psl-build.mjs +1 -1
- package/dist/family__psl-infer.d.mts +1 -1
- package/dist/{index-yNeNt2GO.d.mts → index-BNL2_qQY.d.mts} +9 -9
- package/dist/{index-yNeNt2GO.d.mts.map → index-BNL2_qQY.d.mts.map} +1 -1
- package/dist/{interpreter-IKKTyZNv-D12J5Dcx.mjs → interpreter-Bcc3MIC5-C4dZrobt.mjs} +53 -71
- package/dist/interpreter-Bcc3MIC5-C4dZrobt.mjs.map +1 -0
- package/dist/{middleware-CuGBptK0-C88HCnh5.d.mts → middleware-CuGBptK0-UwVChCr2.d.mts} +2 -2
- package/dist/{middleware-CuGBptK0-C88HCnh5.d.mts.map → middleware-CuGBptK0-UwVChCr2.d.mts.map} +1 -1
- package/dist/middleware-RUh4qBBg.d.mts +1 -0
- package/dist/{migration-BJCmLNwu.d.mts → migration-Csmr6bd8.d.mts} +2 -2
- package/dist/{migration-BJCmLNwu.d.mts.map → migration-Csmr6bd8.d.mts.map} +1 -1
- package/dist/orm-client.d.mts +11 -11
- package/dist/{pack-CUGnCaEh.d.mts → pack-BUv79Jrr.d.mts} +2 -2
- package/dist/{pack-CUGnCaEh.d.mts.map → pack-BUv79Jrr.d.mts.map} +1 -1
- package/dist/{plan-B7g2kDfQ-Bw0784x6.d.mts → plan-B7g2kDfQ-ZD3BfWYx.d.mts} +2 -2
- package/dist/{plan-B7g2kDfQ-Bw0784x6.d.mts.map → plan-B7g2kDfQ-ZD3BfWYx.d.mts.map} +1 -1
- package/dist/plan-CVje8E5I.d.mts +2 -0
- package/dist/{prepared-statement-BHSj2pDk-BL0wOCnq.d.mts → prepared-statement-BHSj2pDk-D9a_Vwr-.d.mts} +14 -14
- package/dist/{prepared-statement-BHSj2pDk-BL0wOCnq.d.mts.map → prepared-statement-BHSj2pDk-D9a_Vwr-.d.mts.map} +1 -1
- package/dist/{psl-build-yBrQQN3r.d.mts → psl-build-BnM1ZTyK.d.mts} +2 -2
- package/dist/psl-build-BnM1ZTyK.d.mts.map +1 -0
- package/dist/{psl-build-SOpIFu24.mjs → psl-build-ph4eUJSB.mjs} +6 -21
- package/dist/psl-build-ph4eUJSB.mjs.map +1 -0
- package/dist/{psl-infer-C8hg8mIS.d.mts → psl-infer-DT5_Lx5r.d.mts} +2 -2
- package/dist/{psl-infer-C8hg8mIS.d.mts.map → psl-infer-DT5_Lx5r.d.mts.map} +1 -1
- package/dist/query-lane-context-D54z0tof.d.mts +1 -0
- package/dist/{query-lane-context-D6o9YrEV-bouFPM6u.d.mts → query-lane-context-D6o9YrEV-BxW3-5e8.d.mts} +3 -3
- package/dist/{query-lane-context-D6o9YrEV-bouFPM6u.d.mts.map → query-lane-context-D6o9YrEV-BxW3-5e8.d.mts.map} +1 -1
- package/dist/relational-core.d.mts +11 -11
- package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
- package/dist/relational-core__ast.d.mts +3 -3
- package/dist/relational-core__codec-descriptor-registry.d.mts +2 -2
- package/dist/relational-core__contract-free.d.mts +2 -2
- package/dist/relational-core__expression.d.mts +1 -1
- package/dist/relational-core__middleware.d.mts +2 -2
- package/dist/relational-core__plan.d.mts +3 -3
- package/dist/relational-core__query-lane-context.d.mts +2 -2
- package/dist/relational-core__types.d.mts +2 -2
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +33 -33
- package/dist/runtime.mjs.map +1 -1
- package/dist/runtime__internal__prepared-query.d.mts +1 -1
- package/dist/{sql-execution-plan-Db0j752I-CI5WbdLi.d.mts → sql-execution-plan-Db0j752I-faODNLY9.d.mts} +2 -2
- package/dist/{sql-execution-plan-Db0j752I-CI5WbdLi.d.mts.map → sql-execution-plan-Db0j752I-faODNLY9.d.mts.map} +1 -1
- package/dist/sql-expression-BXx0Ilj-.mjs +51 -0
- package/dist/sql-expression-BXx0Ilj-.mjs.map +1 -0
- package/dist/sql-expression-D_hbJOgM.d.mts +27 -0
- package/dist/sql-expression-D_hbJOgM.d.mts.map +1 -0
- package/dist/{type-map-BwBI56i3-DDERtzxf.d.mts → type-map-DpfnXzun-DZaSuJXh.d.mts} +5 -5
- package/dist/{type-map-BwBI56i3-DDERtzxf.d.mts.map → type-map-DpfnXzun-DZaSuJXh.d.mts.map} +1 -1
- package/dist/{types-BFPRCYGW-BLH0sK1Y.d.mts → types-BFPRCYGW-CZrZyp1E.d.mts} +2 -2
- package/dist/{types-BFPRCYGW-BLH0sK1Y.d.mts.map → types-BFPRCYGW-CZrZyp1E.d.mts.map} +1 -1
- package/dist/{types-DFJNPLXY-vp6AGe5e.d.mts → types-DFJNPLXY-DyYKIhXA.d.mts} +5 -5
- package/dist/{types-DFJNPLXY-vp6AGe5e.d.mts.map → types-DFJNPLXY-DyYKIhXA.d.mts.map} +1 -1
- package/dist/types-Dul4Za_W.d.mts +1 -0
- package/dist/{types-Yui2yFf6-TP-oRDTX.d.mts → types-Yui2yFf6-Dnc7RNUD.d.mts} +2 -2
- package/dist/{types-Yui2yFf6-TP-oRDTX.d.mts.map → types-Yui2yFf6-Dnc7RNUD.d.mts.map} +1 -1
- package/package.json +19 -18
- package/dist/control-DOGYQMFH.mjs.map +0 -1
- package/dist/control-adapter-jmL_K-jB.d.mts +0 -1
- package/dist/control-kbS8DWF0.d.mts.map +0 -1
- package/dist/interpreter-IKKTyZNv-D12J5Dcx.mjs.map +0 -1
- package/dist/middleware-aoqicpDI.d.mts +0 -1
- package/dist/plan-DiT00Rg8.d.mts +0 -2
- package/dist/psl-build-SOpIFu24.mjs.map +0 -1
- package/dist/psl-build-yBrQQN3r.d.mts.map +0 -1
- package/dist/query-lane-context-BcXiJasG.d.mts +0 -1
- package/dist/types-BvTYXSiS.d.mts +0 -1
|
@@ -1,44 +1,38 @@
|
|
|
1
1
|
import { n as isAuthoredIndexInput } from "./index-naming-Cj1Anq-T-C9TevpPR.mjs";
|
|
2
2
|
import { n as providesPslEntityPlacement } from "./entity-handle-lowering-hook-B3atrRKX.mjs";
|
|
3
|
+
import { s as sqlTextFromCanonical, t as SQL_EXPRESSION_DATA_TYPE_ID } from "./sql-expression-BXx0Ilj-.mjs";
|
|
4
|
+
import { n as checkSqlDefaultBody, o as reservedSqlDefaultBody } from "./validators-BlqrBU7I.mjs";
|
|
3
5
|
import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
|
|
4
|
-
import { n as buildSqlContractFromDefinition } from "./derived-checks-C6psACIj-
|
|
6
|
+
import { n as buildSqlContractFromDefinition } from "./derived-checks-C6psACIj-BSBDa2_9.mjs";
|
|
5
7
|
import { a as getAttribute, c as interpretModelAttribute, d as modelAttributeSpecsFrom, f as sqlAttributeSpecs, i as formatDbAttributeMigrationMessage, l as lowerDefaultFunctionWithRegistry, n as createSqlBinder, o as getNamedArgument, p as storageName, r as fieldSpecContext, s as interpretFieldAttribute, t as PSL_CHECK_ON_STI_VARIANT, u as mapFieldNamesToColumns } from "./sql-attribute-specs-Bs9QDuS7-DmIRJUz9.mjs";
|
|
6
8
|
import { t as defaultTableName } from "./default-table-name-BfFY8qYR-lHNcVmY5.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { checkUncomposedNamespace, getAuthoringFieldPreset, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringTypeConstructorDescriptor,
|
|
9
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
10
|
+
import { checkUncomposedNamespace, getAuthoringFieldPreset, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringTypeConstructorDescriptor, validateAuthoringHelperArguments } from "@prisma/orm-framework/components/authoring";
|
|
9
11
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
10
12
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
11
13
|
import { crossRef } from "@prisma/orm-framework/contract/types";
|
|
12
14
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
15
|
+
import { materializeCodec } from "@prisma/orm-framework/components/codec";
|
|
13
16
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
14
17
|
import { NamespaceDeclarationAst } from "@prisma/orm-framework/psl-parser/syntax";
|
|
15
18
|
import { resolveToOneRelationNullable } from "@prisma/orm-framework/contract-authoring";
|
|
16
|
-
import { materializeCodec } from "@prisma/orm-framework/components/codec";
|
|
17
19
|
import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions";
|
|
18
20
|
import { describeTaggedLiteralFailure } from "@prisma/orm-framework/components/control";
|
|
19
21
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
20
22
|
import { createPslDiagnosticCollector, diagnosticSource, findBlockDescriptor, interpretExtensionBlocks, nodePslSpan, typeReferenceNode } from "@prisma/orm-framework/psl-parser";
|
|
21
23
|
import { UNBOUND_PSL_NAMESPACE_NAME, UNSPECIFIED_PSL_NAMESPACE_ID } from "@prisma/orm-framework/components/psl-ast";
|
|
22
24
|
import { claimedBlockKeywords, enumMemberAttributeDiagnostics, fkRelationPairKey, instantiatePslFieldPreset, mapPslHelperArgs, reportUncomposedNamespace, reportUnknownFieldPreset, requiredOneToOneBackrelationDiagnostic, uncomposedNamespaceDiagnostic, unsupportedBlockDiagnostic } from "@prisma/orm-framework/psl-parser/interpret";
|
|
23
|
-
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-
|
|
25
|
+
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-Bcc3MIC5.mjs
|
|
24
26
|
function contractError(code, message, options) {
|
|
25
27
|
return structuredError(code, message, options);
|
|
26
28
|
}
|
|
27
|
-
/** A
|
|
28
|
-
const PSL_INVALID_JSON_LITERAL = "PSL_INVALID_JSON_LITERAL";
|
|
29
|
-
/** A written value the entry, a cast, or the column's codec refuses. */
|
|
29
|
+
/** A written value the column's codec refuses. */
|
|
30
30
|
const PSL_INVALID_DEFAULT_LITERAL = "PSL_INVALID_DEFAULT_LITERAL";
|
|
31
|
-
/** A
|
|
32
|
-
const
|
|
33
|
-
/** The code the JSON reader raises, so the PSL diagnostic for a bad document is its own. */
|
|
34
|
-
const INVALID_JSON_CODE = "CONTRACT.INVALID_JSON_LITERAL";
|
|
35
|
-
/** The value entries of a stack, by data type id. */
|
|
36
|
-
function valueEntries(support) {
|
|
37
|
-
return Object.entries(support.entries).flatMap(([key, entry]) => isDataTypeLoweringEntry(entry) ? [] : [[key, entry]]);
|
|
38
|
-
}
|
|
31
|
+
/** A single value written as the default of a column that holds a list. */
|
|
32
|
+
const PSL_DEFAULT_LIST_EXPECTED = "PSL_DEFAULT_LIST_EXPECTED";
|
|
39
33
|
/** The entry a tag names, or `undefined` when no pack registered that tag. */
|
|
40
34
|
function entryForTag(support, tag) {
|
|
41
|
-
for (const [key, entry] of
|
|
35
|
+
for (const [key, entry] of Object.entries(support.entries)) if (entry.written.kind === "tag" && entry.written.tag === tag) return {
|
|
42
36
|
key,
|
|
43
37
|
entry
|
|
44
38
|
};
|
|
@@ -48,15 +42,15 @@ function knownTags(support) {
|
|
|
48
42
|
return Object.values(support.entries).flatMap((entry) => entry.written.kind === "tag" ? [entry.written.tag] : []);
|
|
49
43
|
}
|
|
50
44
|
function entryForPlain(support, syntax) {
|
|
51
|
-
for (const [key, entry] of
|
|
45
|
+
for (const [key, entry] of Object.entries(support.entries)) if (entry.written.kind === "plain" && entry.written.syntax === syntax) return {
|
|
52
46
|
key,
|
|
53
47
|
entry
|
|
54
48
|
};
|
|
55
49
|
}
|
|
56
|
-
/** The text an entry reads: a tag's
|
|
50
|
+
/** The text an entry reads: a tag's text, a string's value, or the word a boolean is written as. */
|
|
57
51
|
function plainText(written) {
|
|
58
52
|
switch (written.kind) {
|
|
59
|
-
case "tag": return written.
|
|
53
|
+
case "tag": return written.text;
|
|
60
54
|
case "string": return written.text;
|
|
61
55
|
case "boolean": return String(written.value);
|
|
62
56
|
case "number": return written.text;
|
|
@@ -65,9 +59,6 @@ function plainText(written) {
|
|
|
65
59
|
function messageOf(error) {
|
|
66
60
|
return error instanceof Error ? error.message : String(error);
|
|
67
61
|
}
|
|
68
|
-
function isJsonRefusal(error) {
|
|
69
|
-
return isStructuredError(error) && error.code === INVALID_JSON_CODE;
|
|
70
|
-
}
|
|
71
62
|
/** Read one written value through the entry for its syntax. */
|
|
72
63
|
function readValue(support, written, elementIndex) {
|
|
73
64
|
const refuse = (refusal) => ({
|
|
@@ -92,7 +83,6 @@ function readValue(support, written, elementIndex) {
|
|
|
92
83
|
const classified = form.classify(text);
|
|
93
84
|
if (classified === void 0) return refuse({
|
|
94
85
|
kind: "unreadable",
|
|
95
|
-
json: false,
|
|
96
86
|
message: `no data type of this target holds the number ${text}`
|
|
97
87
|
});
|
|
98
88
|
return {
|
|
@@ -112,7 +102,6 @@ function readValue(support, written, elementIndex) {
|
|
|
112
102
|
} catch (error) {
|
|
113
103
|
return refuse({
|
|
114
104
|
kind: "unreadable",
|
|
115
|
-
json: isJsonRefusal(error),
|
|
116
105
|
message: messageOf(error)
|
|
117
106
|
});
|
|
118
107
|
}
|
|
@@ -145,7 +134,6 @@ function castInto(support, columnType, typed, elementIndex) {
|
|
|
145
134
|
ok: false,
|
|
146
135
|
refusal: {
|
|
147
136
|
kind: "unreadable",
|
|
148
|
-
json: isJsonRefusal(error),
|
|
149
137
|
message: messageOf(error),
|
|
150
138
|
elementIndex
|
|
151
139
|
}
|
|
@@ -215,7 +203,6 @@ function readDataTypeDefault(input) {
|
|
|
215
203
|
ok: false,
|
|
216
204
|
refusal: {
|
|
217
205
|
kind: "unreadable",
|
|
218
|
-
json: false,
|
|
219
206
|
message: "a list holds values, not other lists",
|
|
220
207
|
elementIndex
|
|
221
208
|
}
|
|
@@ -255,7 +242,6 @@ function readListIntoScalar(input) {
|
|
|
255
242
|
ok: false,
|
|
256
243
|
refusal: {
|
|
257
244
|
kind: "unreadable",
|
|
258
|
-
json: false,
|
|
259
245
|
message: "a list holds values, not other lists",
|
|
260
246
|
elementIndex
|
|
261
247
|
}
|
|
@@ -281,7 +267,6 @@ function readListIntoScalar(input) {
|
|
|
281
267
|
ok: false,
|
|
282
268
|
refusal: {
|
|
283
269
|
kind: "unreadable",
|
|
284
|
-
json: isJsonRefusal(error),
|
|
285
270
|
message: messageOf(error),
|
|
286
271
|
elementIndex: void 0
|
|
287
272
|
}
|
|
@@ -301,27 +286,27 @@ function lowerDataTypeDefault(input) {
|
|
|
301
286
|
switch (refusal.kind) {
|
|
302
287
|
case "unreadable": return {
|
|
303
288
|
ok: false,
|
|
304
|
-
code:
|
|
289
|
+
code: "PSL_INVALID_LITERAL",
|
|
305
290
|
message: `${where}: ${refusal.message}`
|
|
306
291
|
};
|
|
307
292
|
case "unknown-tag": return {
|
|
308
293
|
ok: false,
|
|
309
|
-
code: "
|
|
294
|
+
code: "PSL_UNKNOWN_LITERAL_TAG",
|
|
310
295
|
message: `Unknown literal tag "${refusal.tag}". Known tags: ${refusal.known.join(", ")}.`
|
|
311
296
|
};
|
|
312
297
|
case "unwritable": return {
|
|
313
298
|
ok: false,
|
|
314
|
-
code:
|
|
299
|
+
code: "PSL_VALUE_TYPE_INCOMPATIBLE",
|
|
315
300
|
message: `${where}: this target has no data type for a ${refusal.syntax} value`
|
|
316
301
|
};
|
|
317
302
|
case "not-a-list": return {
|
|
318
303
|
ok: false,
|
|
319
|
-
code:
|
|
304
|
+
code: PSL_DEFAULT_LIST_EXPECTED,
|
|
320
305
|
message: `${where}: this column holds a list, so its default is a list literal, as in [1, 2]`
|
|
321
306
|
};
|
|
322
307
|
case "no-cast": return {
|
|
323
308
|
ok: false,
|
|
324
|
-
code:
|
|
309
|
+
code: "PSL_VALUE_TYPE_INCOMPATIBLE",
|
|
325
310
|
message: `${where}: ${refusal.columnType} has no cast from ${refusal.valueType}; ${describeCasts(refusal.casts)}`
|
|
326
311
|
};
|
|
327
312
|
case "undecodable": return {
|
|
@@ -623,44 +608,31 @@ function resolveFieldTypeDescriptor(input) {
|
|
|
623
608
|
descriptor
|
|
624
609
|
};
|
|
625
610
|
}
|
|
611
|
+
const PSL_INVALID_DEFAULT_SQL = "PSL_INVALID_DEFAULT_SQL";
|
|
626
612
|
const TAGGED_LITERAL_CANONICALIZATION_CODES = {
|
|
627
613
|
nul: "PSL_TAGGED_LITERAL_NUL",
|
|
628
614
|
"too-large": "PSL_TAGGED_LITERAL_TOO_LARGE"
|
|
629
615
|
};
|
|
630
|
-
function
|
|
616
|
+
function readTaggedLiteral(literal, support, source) {
|
|
631
617
|
const reject = (code, message) => ({
|
|
632
618
|
ok: false,
|
|
633
|
-
kind: "owned",
|
|
634
619
|
diagnostic: {
|
|
635
620
|
code,
|
|
636
621
|
message,
|
|
637
622
|
...source.at(literal.span)
|
|
638
623
|
}
|
|
639
624
|
});
|
|
640
|
-
|
|
641
|
-
if (entry === void 0) return reject("PSL_UNKNOWN_DEFAULT_LITERAL_TAG", `Unknown literal tag "${literal.tag}". Known tags: ${knownTags(support).join(", ")}.`);
|
|
625
|
+
if (entryForTag(support, literal.tag) === void 0) return reject("PSL_UNKNOWN_LITERAL_TAG", `Unknown literal tag "${literal.tag}". Known tags: ${knownTags(support).join(", ")}.`);
|
|
642
626
|
const { canonicalization } = literal;
|
|
643
627
|
if (!canonicalization.ok) return reject(TAGGED_LITERAL_CANONICALIZATION_CODES[canonicalization.reason], describeTaggedLiteralFailure(canonicalization.reason));
|
|
644
|
-
|
|
628
|
+
return {
|
|
645
629
|
ok: true,
|
|
646
630
|
written: {
|
|
647
631
|
kind: "tag",
|
|
648
632
|
tag: literal.tag,
|
|
649
|
-
|
|
633
|
+
text: canonicalization.body
|
|
650
634
|
}
|
|
651
635
|
};
|
|
652
|
-
const result = entry.lower({
|
|
653
|
-
literal: {
|
|
654
|
-
tag: literal.tag,
|
|
655
|
-
body: canonicalization.body,
|
|
656
|
-
span: literal.span
|
|
657
|
-
},
|
|
658
|
-
context
|
|
659
|
-
});
|
|
660
|
-
return result.ok ? result : {
|
|
661
|
-
...result,
|
|
662
|
-
kind: "external"
|
|
663
|
-
};
|
|
664
636
|
}
|
|
665
637
|
function lowerDefaultForField(input) {
|
|
666
638
|
const node = getAttribute(input.field.attributes, "default")?.node;
|
|
@@ -687,12 +659,6 @@ function lowerDefaultForField(input) {
|
|
|
687
659
|
});
|
|
688
660
|
if (interpreted === void 0) return {};
|
|
689
661
|
const value = interpreted.value;
|
|
690
|
-
const context = {
|
|
691
|
-
sourceId: input.sources.sourceFileFor(node.syntax).filename,
|
|
692
|
-
modelName: input.modelName,
|
|
693
|
-
fieldName: input.fieldName,
|
|
694
|
-
columnCodecId: input.columnDescriptor.codecId
|
|
695
|
-
};
|
|
696
662
|
const readAsLiteral = (written) => {
|
|
697
663
|
const lowered = lowerDataTypeDefault({
|
|
698
664
|
written,
|
|
@@ -729,21 +695,28 @@ function lowerDefaultForField(input) {
|
|
|
729
695
|
kind: "number",
|
|
730
696
|
text: element.text
|
|
731
697
|
};
|
|
732
|
-
const
|
|
733
|
-
if (!
|
|
734
|
-
|
|
735
|
-
else input.diagnostics.pushExternal(lowered.diagnostic);
|
|
698
|
+
const literal = readTaggedLiteral(element, input.dataTypeSupport, source);
|
|
699
|
+
if (!literal.ok) {
|
|
700
|
+
input.diagnostics.push(literal.diagnostic);
|
|
736
701
|
return { ok: false };
|
|
737
702
|
}
|
|
738
|
-
|
|
703
|
+
return literal.written;
|
|
704
|
+
};
|
|
705
|
+
const sqlExpressionDefault = (text, span) => {
|
|
706
|
+
const reserved = reservedSqlDefaultBody(text);
|
|
707
|
+
const refusal = reserved === void 0 ? checkSqlDefaultBody(text) : `Write @default(${reserved}()) instead of sql\`${reserved}()\`; ${reserved}() is a Prisma default function, not raw SQL.`;
|
|
708
|
+
if (refusal !== void 0) {
|
|
739
709
|
input.diagnostics.push({
|
|
740
|
-
code:
|
|
741
|
-
message:
|
|
742
|
-
...source.at(
|
|
710
|
+
code: PSL_INVALID_DEFAULT_SQL,
|
|
711
|
+
message: refusal,
|
|
712
|
+
...source.at(span)
|
|
743
713
|
});
|
|
744
|
-
return {
|
|
714
|
+
return {};
|
|
745
715
|
}
|
|
746
|
-
return
|
|
716
|
+
return { defaultValue: {
|
|
717
|
+
kind: "function",
|
|
718
|
+
expression: text
|
|
719
|
+
} };
|
|
747
720
|
};
|
|
748
721
|
if (input.columnDescriptor.valueSet !== void 0) {
|
|
749
722
|
if (typeof value === "string") return { defaultValue: {
|
|
@@ -782,6 +755,16 @@ function lowerDefaultForField(input) {
|
|
|
782
755
|
kind: "number",
|
|
783
756
|
text: value.text
|
|
784
757
|
});
|
|
758
|
+
if ("tag" in value) {
|
|
759
|
+
const literal = readTaggedLiteral(value, input.dataTypeSupport, source);
|
|
760
|
+
if (!literal.ok) {
|
|
761
|
+
input.diagnostics.push(literal.diagnostic);
|
|
762
|
+
return {};
|
|
763
|
+
}
|
|
764
|
+
const read = readValue(input.dataTypeSupport, literal.written, void 0);
|
|
765
|
+
if (read.ok && read.typed.type === SQL_EXPRESSION_DATA_TYPE_ID) return sqlExpressionDefault(sqlTextFromCanonical(read.typed.value), value.span);
|
|
766
|
+
return readAsLiteral(literal.written);
|
|
767
|
+
}
|
|
785
768
|
if (typeof value === "object") {
|
|
786
769
|
const context = {
|
|
787
770
|
sourceId: input.sources.sourceFileFor(node.syntax).filename,
|
|
@@ -789,7 +772,7 @@ function lowerDefaultForField(input) {
|
|
|
789
772
|
fieldName: input.fieldName,
|
|
790
773
|
columnCodecId: input.columnDescriptor.codecId
|
|
791
774
|
};
|
|
792
|
-
const lowered =
|
|
775
|
+
const lowered = lowerDefaultFunctionWithRegistry({
|
|
793
776
|
call: value,
|
|
794
777
|
registry: input.defaultFunctionRegistry,
|
|
795
778
|
context,
|
|
@@ -800,7 +783,6 @@ function lowerDefaultForField(input) {
|
|
|
800
783
|
else input.diagnostics.pushExternal(lowered.diagnostic);
|
|
801
784
|
return {};
|
|
802
785
|
}
|
|
803
|
-
if ("written" in lowered) return readAsLiteral(lowered.written);
|
|
804
786
|
if (lowered.value.kind === "storage") return { defaultValue: lowered.value.defaultValue };
|
|
805
787
|
const generatorDescriptor = input.generatorDescriptorById.get(lowered.value.generated.id);
|
|
806
788
|
if (!generatorDescriptor) {
|
|
@@ -3457,4 +3439,4 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
3457
3439
|
//#endregion
|
|
3458
3440
|
export { interpretPslDocumentToSqlContract as a, resolveFieldTypeDescriptor as c, indexFkRelations as i, buildEntityTypesByDiscriminator as n, normalizeReferentialAction as o, entryForTag as r, readDataTypeDefault as s, applyBackrelationCandidates as t };
|
|
3459
3441
|
|
|
3460
|
-
//# sourceMappingURL=interpreter-
|
|
3442
|
+
//# sourceMappingURL=interpreter-Bcc3MIC5-C4dZrobt.mjs.map
|