@prisma/orm-family-sql 8.0.0-rc.19-dev.6 → 8.0.0-rc.19-dev.8
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/{authoring-entity-types-DUQLeBf_-DSWWvkLJ.d.mts → authoring-entity-types-CgKIgWq5-Dxf_T0Ih.d.mts} +3 -3
- package/dist/authoring-entity-types-CgKIgWq5-Dxf_T0Ih.d.mts.map +1 -0
- package/dist/{config-types-BLDwd9wS.mjs → config-types-BbBY5_GQ.mjs} +2 -2
- package/dist/{config-types-BLDwd9wS.mjs.map → config-types-BbBY5_GQ.mjs.map} +1 -1
- package/dist/{contract-builder-CNeGxqP_.mjs → contract-builder-D7cTmhfs.mjs} +4 -5
- package/dist/contract-builder-D7cTmhfs.mjs.map +1 -0
- package/dist/contract-prisma7__provider.mjs +10 -4
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.mjs +2 -2
- package/dist/contract.d.mts +3 -3
- package/dist/contract.mjs +3 -3
- package/dist/contract__data-type-support.d.mts +2 -2
- package/dist/contract__data-type-support.mjs +2 -2
- package/dist/contract__data-type.d.mts +2 -2
- package/dist/contract__data-type.mjs +2 -2
- package/dist/{control-Dv1ea79q.d.mts → control-BW6gbqvb.d.mts} +2 -2
- package/dist/{control-Dv1ea79q.d.mts.map → control-BW6gbqvb.d.mts.map} +1 -1
- package/dist/{control-Cih61sJa.mjs → control-DnFJf5_F.mjs} +3 -3
- package/dist/{control-Cih61sJa.mjs.map → control-DnFJf5_F.mjs.map} +1 -1
- package/dist/{data-type-CUJMZOHo.mjs → data-type-BMnEHaW3.mjs} +2 -17
- package/dist/data-type-BMnEHaW3.mjs.map +1 -0
- package/dist/{data-type-CWFhlpaq.d.mts → data-type-iatMyRs6.d.mts} +2 -9
- package/dist/data-type-iatMyRs6.d.mts.map +1 -0
- package/dist/data-type-support-a9BR-PbH.d.mts +7 -0
- package/dist/data-type-support-a9BR-PbH.d.mts.map +1 -0
- package/dist/data-type-support-juGV2d9c.mjs +9 -0
- package/dist/data-type-support-juGV2d9c.mjs.map +1 -0
- package/dist/{derived-checks-iXF3y0Ki-28vqz_8w.mjs → derived-checks-D5HVRvqN-B37oe30Z.mjs} +2 -2
- package/dist/{derived-checks-iXF3y0Ki-28vqz_8w.mjs.map → derived-checks-D5HVRvqN-B37oe30Z.mjs.map} +1 -1
- package/dist/{exports-CRROThzp-BNz0pGj0.mjs → exports-C3wGYtID-Bg6ThaBe.mjs} +88 -39
- package/dist/exports-C3wGYtID-Bg6ThaBe.mjs.map +1 -0
- package/dist/family.d.mts +3 -3
- package/dist/family.mjs +4 -4
- package/dist/family__control.d.mts +1 -1
- package/dist/family__control.mjs +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-build.d.mts +1 -1
- package/dist/family__psl-build.mjs +1 -1
- package/dist/{generator-functions-DuDZSQHE-Dl5EP61A.mjs → generator-functions-D_qdqBV--BoeJwWsz.mjs} +4 -4
- package/dist/generator-functions-D_qdqBV--BoeJwWsz.mjs.map +1 -0
- package/dist/{index-3aEIvk82.d.mts → index-BAxGJxON.d.mts} +11 -9
- package/dist/index-BAxGJxON.d.mts.map +1 -0
- package/dist/{interpreter-BGgim2OE-D9BG-4aU.mjs → interpreter-BDpym-rc-BZVFp5GU.mjs} +112 -77
- package/dist/interpreter-BDpym-rc-BZVFp5GU.mjs.map +1 -0
- package/dist/orm-client.d.mts +1 -1
- package/dist/orm-client.mjs +1 -1
- package/dist/{pack-B5_CfdgT.mjs → pack-BifOs83a.mjs} +3 -3
- package/dist/{pack-B5_CfdgT.mjs.map → pack-BifOs83a.mjs.map} +1 -1
- package/dist/{pack-BJ53Inwa.d.mts → pack-CdaZMfI_.d.mts} +2 -2
- package/dist/{pack-BJ53Inwa.d.mts.map → pack-CdaZMfI_.d.mts.map} +1 -1
- package/dist/{psl-build-prdUw3sC.d.mts → psl-build-BYXXz2XD.d.mts} +2 -2
- package/dist/{psl-build-prdUw3sC.d.mts.map → psl-build-BYXXz2XD.d.mts.map} +1 -1
- package/dist/{psl-build-D5VG40ej.mjs → psl-build-fwoI6rBO.mjs} +3 -4
- package/dist/{psl-build-D5VG40ej.mjs.map → psl-build-fwoI6rBO.mjs.map} +1 -1
- package/dist/{psl-field-resolution-C9zwpsAu-DCc7Eifv.mjs → psl-field-resolution-C5KQ7kzP-DH8oSBIL.mjs} +4 -22
- package/dist/psl-field-resolution-C5KQ7kzP-DH8oSBIL.mjs.map +1 -0
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +18 -18
- package/dist/authoring-entity-types-DUQLeBf_-DSWWvkLJ.d.mts.map +0 -1
- package/dist/contract-builder-CNeGxqP_.mjs.map +0 -1
- package/dist/data-type-CUJMZOHo.mjs.map +0 -1
- package/dist/data-type-CWFhlpaq.d.mts.map +0 -1
- package/dist/data-type-support-C5-XxxeB.mjs +0 -364
- package/dist/data-type-support-C5-XxxeB.mjs.map +0 -1
- package/dist/data-type-support-CBcYhSkD.d.mts +0 -88
- package/dist/data-type-support-CBcYhSkD.d.mts.map +0 -1
- package/dist/exports-CRROThzp-BNz0pGj0.mjs.map +0 -1
- package/dist/generator-functions-DuDZSQHE-Dl5EP61A.mjs.map +0 -1
- package/dist/index-3aEIvk82.d.mts.map +0 -1
- package/dist/interpreter-BGgim2OE-D9BG-4aU.mjs.map +0 -1
- package/dist/psl-field-resolution-C9zwpsAu-DCc7Eifv.mjs.map +0 -1
|
@@ -4,13 +4,13 @@ import { n as providesPslEntityPlacement } from "./entity-handle-lowering-hook-B
|
|
|
4
4
|
import "./foreign-key-materialization-BPQqd0qF.mjs";
|
|
5
5
|
import { p as sqlTextFromStored } from "./sql-expression-BJCuy-WI.mjs";
|
|
6
6
|
import { t as deriveValueSetFromEntity } from "./value-set-derivation-hook-Di9JZ0X7.mjs";
|
|
7
|
-
import { n as buildSqlContractFromDefinition } from "./derived-checks-
|
|
7
|
+
import { n as buildSqlContractFromDefinition } from "./derived-checks-D5HVRvqN-B37oe30Z.mjs";
|
|
8
8
|
import { i as mapFieldNamesToColumns, n as getAttribute, o as storageName, r as getNamedArgument, t as formatDbAttributeMigrationMessage } from "./psl-attribute-parsing-BCsFWsSp-LaNsbcrw.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { _ as modelSpecContext, b as sqlAttributeSpecs, d as interpretModelAttribute, f as lowerEnumDefault, g as modelCoordinateKey, h as modelAttributeSpecsFrom, l as instantiatePslTypeConstructor, m as lowerTypeGenerators, n as collectResolvedFields, o as fieldSpecContext, p as lowerTypeDefault, r as contractError, s as getAuthoringEntity, t as PSL_CHECK_ON_STI_VARIANT, u as interpretFieldAttribute, y as resolveFieldTypeDescriptor } from "./psl-field-resolution-C5KQ7kzP-DH8oSBIL.mjs";
|
|
10
10
|
import { t as defaultTableName } from "./default-table-name-BfFY8qYR-lHNcVmY5.mjs";
|
|
11
11
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
12
12
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
13
|
-
import { instantiateAuthoringEntityType, instantiateAuthoringTypeAlias, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringModelAttributeDescriptor, resolveTypeAliasGenerators } from "@prisma/orm-framework/components/authoring";
|
|
13
|
+
import { applyDiscriminatorRule, describeDiscriminatorRefusal, encodeEnumMembers, instantiateAuthoringEntityType, instantiateAuthoringTypeAlias, instantiateAuthoringTypeConstructor, isAuthoringEntityTypeDescriptor, isAuthoringModelAttributeDescriptor, resolveTypeAliasGenerators } from "@prisma/orm-framework/components/authoring";
|
|
14
14
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
15
15
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
16
16
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
@@ -21,7 +21,7 @@ import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions
|
|
|
21
21
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
22
22
|
import { contributedTypeAliasOf, createPslDiagnosticCollector, diagnosticSource, findBlockDescriptor, interpretExtensionBlocks, nodePslSpan, resolveTypeAliases, typeAliasAttributeNames, typeAliasSpecContext, typeReferenceNode } from "@prisma/orm-framework/psl-parser";
|
|
23
23
|
import { claimedBlockKeywords, enumMemberAttributeDiagnostics, fkRelationPairKey, requiredOneToOneBackrelationDiagnostic, unsupportedBlockDiagnostic } from "@prisma/orm-framework/psl-parser/interpret";
|
|
24
|
-
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-
|
|
24
|
+
//#region ../../../2-sql/2-authoring/contract-psl/dist/interpreter-BDpym-rc.mjs
|
|
25
25
|
function describeUnsupportedSqlAliasAttribute(attribute) {
|
|
26
26
|
return attribute.name.startsWith("db.") ? formatDbAttributeMigrationMessage(attribute) : void 0;
|
|
27
27
|
}
|
|
@@ -1028,7 +1028,7 @@ function buildModelNodeFromPsl(input) {
|
|
|
1028
1028
|
family: input.familyId,
|
|
1029
1029
|
target: input.targetId,
|
|
1030
1030
|
codecLookup: input.codecLookup,
|
|
1031
|
-
|
|
1031
|
+
dataTypes: input.dataTypes,
|
|
1032
1032
|
modelName: model.name,
|
|
1033
1033
|
storageName: tableName,
|
|
1034
1034
|
fieldStorageName: (fieldName) => {
|
|
@@ -1415,15 +1415,10 @@ function buildValueObjectNodes(input) {
|
|
|
1415
1415
|
};
|
|
1416
1416
|
});
|
|
1417
1417
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
if (textDataTypes.length === 0) throw new InternalError("The stack names no text data types, so no column can be a discriminator; the target names its text types in its authoring contributions.");
|
|
1421
|
-
const dataType = codecLookup.descriptorFor(column.codecId)?.dataType;
|
|
1422
|
-
return dataType !== void 0 && textDataTypes.includes(dataType);
|
|
1423
|
-
}
|
|
1424
|
-
function collectPolymorphismDeclarations(identities, symbols, sources, binder, specContextFor, discriminatorColumnOf, codecLookup, dataTypes, textDataTypes, diagnostics) {
|
|
1425
|
-
const discriminatorDeclarations = /* @__PURE__ */ new Map();
|
|
1418
|
+
function collectPolymorphismDeclarations(identities, symbols, sources, binder, specContextFor, discriminatorFieldOf, codecLookup, dataTypes, diagnostics) {
|
|
1419
|
+
const pendingDiscriminators = /* @__PURE__ */ new Map();
|
|
1426
1420
|
const pendingBaseDeclarations = /* @__PURE__ */ new Map();
|
|
1421
|
+
const reported = { discriminators: /* @__PURE__ */ new Set() };
|
|
1427
1422
|
for (const { model, namespaceId, key } of identities.values()) {
|
|
1428
1423
|
const source = diagnosticSource(sources, model.node.syntax);
|
|
1429
1424
|
const discriminatorNode = getAttribute(model.attributes, "discriminator")?.node;
|
|
@@ -1437,23 +1432,16 @@ function collectPolymorphismDeclarations(identities, symbols, sources, binder, s
|
|
|
1437
1432
|
binder,
|
|
1438
1433
|
diagnostics
|
|
1439
1434
|
});
|
|
1440
|
-
if (parsed !== void 0) {
|
|
1441
|
-
|
|
1442
|
-
const discField = model.fields[parsed.field];
|
|
1443
|
-
const column = discriminatorColumnOf(model, parsed.field);
|
|
1444
|
-
if (column === void 0 || !isTextColumn(column, codecLookup, textDataTypes)) diagnostics.push({
|
|
1445
|
-
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
1446
|
-
message: `Discriminator field "${parsed.field}" on model "${model.name}" must be text, such as String, but is "${discField?.typeName ?? parsed.field}"`,
|
|
1447
|
-
...source.at(span)
|
|
1448
|
-
});
|
|
1449
|
-
else discriminatorDeclarations.set(key, {
|
|
1435
|
+
if (parsed !== void 0) pendingDiscriminators.set(key, {
|
|
1436
|
+
declaration: {
|
|
1450
1437
|
model,
|
|
1451
1438
|
fieldName: parsed.field,
|
|
1452
|
-
|
|
1453
|
-
span,
|
|
1439
|
+
span: nodePslSpan(discriminatorNode.syntax, sources),
|
|
1454
1440
|
source
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1441
|
+
},
|
|
1442
|
+
field: discriminatorFieldOf(model, parsed.field)
|
|
1443
|
+
});
|
|
1444
|
+
else reported.discriminators.add(key);
|
|
1457
1445
|
}
|
|
1458
1446
|
const baseNode = getAttribute(model.attributes, "base")?.node;
|
|
1459
1447
|
if (baseNode !== void 0) {
|
|
@@ -1480,57 +1468,91 @@ function collectPolymorphismDeclarations(identities, symbols, sources, binder, s
|
|
|
1480
1468
|
}
|
|
1481
1469
|
}
|
|
1482
1470
|
}
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
dataTypes,
|
|
1491
|
-
diagnostics
|
|
1492
|
-
})
|
|
1471
|
+
const discriminatorDeclarations = /* @__PURE__ */ new Map();
|
|
1472
|
+
const values = /* @__PURE__ */ new Map();
|
|
1473
|
+
for (const [baseKey, { declaration, field }] of pendingDiscriminators) {
|
|
1474
|
+
const accepted = acceptedDiscriminator(declaration, field, [...pendingBaseDeclarations].filter(([, base]) => base.base.key === baseKey), {
|
|
1475
|
+
codecLookup,
|
|
1476
|
+
dataTypes,
|
|
1477
|
+
diagnostics
|
|
1493
1478
|
});
|
|
1479
|
+
if (accepted === void 0) {
|
|
1480
|
+
reported.discriminators.add(baseKey);
|
|
1481
|
+
continue;
|
|
1482
|
+
}
|
|
1483
|
+
discriminatorDeclarations.set(baseKey, declaration);
|
|
1484
|
+
for (const [variantKey, value] of accepted) values.set(variantKey, value);
|
|
1494
1485
|
}
|
|
1486
|
+
const baseDeclarations = /* @__PURE__ */ new Map();
|
|
1487
|
+
for (const [key, { model, namespaceId, source, base, span }] of pendingBaseDeclarations) baseDeclarations.set(key, {
|
|
1488
|
+
model,
|
|
1489
|
+
namespaceId,
|
|
1490
|
+
source,
|
|
1491
|
+
base,
|
|
1492
|
+
span,
|
|
1493
|
+
value: values.get(key)
|
|
1494
|
+
});
|
|
1495
1495
|
return {
|
|
1496
1496
|
discriminatorDeclarations,
|
|
1497
|
-
baseDeclarations
|
|
1497
|
+
baseDeclarations,
|
|
1498
|
+
reported
|
|
1498
1499
|
};
|
|
1499
1500
|
}
|
|
1500
1501
|
/**
|
|
1501
|
-
*
|
|
1502
|
+
* The stored discriminator value of each variant, by the variant's key, when the discriminator rule accepts the field; `undefined` when it refuses the field. A refusal is reported at the `@@discriminator` attribute or at the `@@base` value it is about.
|
|
1502
1503
|
*/
|
|
1503
|
-
function
|
|
1504
|
-
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
},
|
|
1512
|
-
|
|
1513
|
-
column: discriminator.column,
|
|
1504
|
+
function acceptedDiscriminator(declaration, discriminatorField, bases, input) {
|
|
1505
|
+
const { model, fieldName } = declaration;
|
|
1506
|
+
const baseByKey = new Map(bases);
|
|
1507
|
+
const decision = applyDiscriminatorRule({
|
|
1508
|
+
field: discriminatorField.field,
|
|
1509
|
+
variants: bases.map(([key, base]) => ({
|
|
1510
|
+
key,
|
|
1511
|
+
written: writtenBaseValue(base)
|
|
1512
|
+
})),
|
|
1513
|
+
subject: `Field "${model.name}.${fieldName}"`,
|
|
1514
1514
|
codecLookup: input.codecLookup,
|
|
1515
|
-
dataTypes: input.dataTypes
|
|
1516
|
-
subject: `Field "${discriminator.model.name}.${discriminator.fieldName}"`,
|
|
1517
|
-
sourceElementIndexes: void 0
|
|
1515
|
+
dataTypes: input.dataTypes
|
|
1518
1516
|
});
|
|
1519
|
-
|
|
1517
|
+
const baseOf = (variantKey) => {
|
|
1518
|
+
const base = baseByKey.get(variantKey);
|
|
1519
|
+
invariant(base !== void 0, "A refused @@base value belongs to a collected variant");
|
|
1520
|
+
return base;
|
|
1521
|
+
};
|
|
1522
|
+
const subject = {
|
|
1523
|
+
modelName: model.name,
|
|
1524
|
+
fieldName,
|
|
1525
|
+
typeName: model.fields[fieldName]?.typeName ?? fieldName,
|
|
1526
|
+
enumName: discriminatorField.enumName,
|
|
1527
|
+
variantName: (variantKey) => baseOf(variantKey).model.name
|
|
1528
|
+
};
|
|
1529
|
+
for (const refusal of decision.fieldRefusals) input.diagnostics.push({
|
|
1530
|
+
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
1531
|
+
message: describeDiscriminatorRefusal(refusal, subject),
|
|
1532
|
+
...declaration.source.at(declaration.span)
|
|
1533
|
+
});
|
|
1534
|
+
if (decision.fieldRefusals.length > 0) return void 0;
|
|
1535
|
+
for (const refusal of decision.variantRefusals) {
|
|
1536
|
+
const base = baseOf(refusal.key);
|
|
1520
1537
|
input.diagnostics.push({
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1538
|
+
...refusal.kind === "unreadable" ? refusal.refusal : {
|
|
1539
|
+
code: "PSL_INVALID_ATTRIBUTE_ARGUMENT",
|
|
1540
|
+
message: describeDiscriminatorRefusal(refusal, subject)
|
|
1541
|
+
},
|
|
1542
|
+
...base.source.at(base.written.span)
|
|
1524
1543
|
});
|
|
1525
|
-
return;
|
|
1526
1544
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1545
|
+
return decision.values;
|
|
1546
|
+
}
|
|
1547
|
+
/** A `@@base` value as it is written; the grammar reads only a quoted string there. */
|
|
1548
|
+
function writtenBaseValue(base) {
|
|
1549
|
+
if (base.written.written === void 0) throw new InternalError("A @@base value is a quoted string, never a tagged literal.");
|
|
1550
|
+
return base.written.written;
|
|
1529
1551
|
}
|
|
1530
1552
|
function modelLabel(namespaceId, modelName, qualified) {
|
|
1531
1553
|
return qualified ? `${namespaceId}.${modelName}` : modelName;
|
|
1532
1554
|
}
|
|
1533
|
-
function resolvePolymorphism(models, physicalNames, discriminatorDeclarations, baseDeclarations, syntheticPkFieldsByVariant, stiBaseFieldsByBase, diagnostics) {
|
|
1555
|
+
function resolvePolymorphism(models, physicalNames, discriminatorDeclarations, baseDeclarations, reported, syntheticPkFieldsByVariant, stiBaseFieldsByBase, diagnostics) {
|
|
1534
1556
|
let patched = models;
|
|
1535
1557
|
for (const [baseKey, fieldNames] of stiBaseFieldsByBase) {
|
|
1536
1558
|
const baseModel = patched[baseKey];
|
|
@@ -1569,6 +1591,7 @@ function resolvePolymorphism(models, physicalNames, discriminatorDeclarations, b
|
|
|
1569
1591
|
variants[baseDecl.value] = crossRef(variantName, baseDecl.namespaceId);
|
|
1570
1592
|
}
|
|
1571
1593
|
if (Object.keys(variants).length === 0) {
|
|
1594
|
+
if ([...baseDeclarations.values()].some((baseDecl) => baseDecl.base.key === modelKey && baseDecl.value === void 0)) continue;
|
|
1572
1595
|
diagnostics.push({
|
|
1573
1596
|
code: "PSL_ORPHANED_DISCRIMINATOR",
|
|
1574
1597
|
message: `Model "${modelName}" has @@discriminator but no variant models declare @@base(${modelName}, ...)`,
|
|
@@ -1588,6 +1611,7 @@ function resolvePolymorphism(models, physicalNames, discriminatorDeclarations, b
|
|
|
1588
1611
|
for (const [variantKey, baseDecl] of baseDeclarations) {
|
|
1589
1612
|
const baseName = baseDecl.base.model.name;
|
|
1590
1613
|
if (!discriminatorDeclarations.has(baseDecl.base.key)) {
|
|
1614
|
+
if (reported.discriminators.has(baseDecl.base.key)) continue;
|
|
1591
1615
|
const qualified = baseDecl.namespaceId !== baseDecl.base.namespaceId;
|
|
1592
1616
|
const variantLabel = modelLabel(baseDecl.namespaceId, baseDecl.model.name, qualified);
|
|
1593
1617
|
const baseLabel = modelLabel(baseDecl.base.namespaceId, baseName, qualified);
|
|
@@ -1927,18 +1951,11 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
1927
1951
|
family: input.target.familyId,
|
|
1928
1952
|
target: input.target.targetId,
|
|
1929
1953
|
codecLookup: input.codecLookup,
|
|
1930
|
-
|
|
1954
|
+
dataTypes: input.dataTypes,
|
|
1931
1955
|
sourceId: source.sources.sourceFileFor(source.node).filename,
|
|
1932
1956
|
diagnostics: { push: (d) => {
|
|
1933
1957
|
diagnostics.pushExternal(blindCast(d));
|
|
1934
1958
|
} },
|
|
1935
|
-
readWrittenValueForCodec: ({ written, codecId, subject }) => input.codecLookup.descriptorFor(codecId) === void 0 ? void 0 : readWrittenValueForCodec({
|
|
1936
|
-
written,
|
|
1937
|
-
codecId,
|
|
1938
|
-
codecLookup: input.codecLookup,
|
|
1939
|
-
dataTypes: input.dataTypes,
|
|
1940
|
-
subject
|
|
1941
|
-
}),
|
|
1942
1959
|
...ifDefined("enumInferenceCodecs", input.enumInferenceCodecs)
|
|
1943
1960
|
},
|
|
1944
1961
|
diagnostics
|
|
@@ -1953,7 +1970,7 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
1953
1970
|
target: input.target.targetId,
|
|
1954
1971
|
...ifDefined("enumInferenceCodecs", input.enumInferenceCodecs),
|
|
1955
1972
|
codecLookup: input.codecLookup,
|
|
1956
|
-
|
|
1973
|
+
dataTypes: input.dataTypes,
|
|
1957
1974
|
sourceId: source.sources.sourceFileFor(source.node).filename,
|
|
1958
1975
|
diagnostics: { push: (d) => {
|
|
1959
1976
|
diagnostics.pushExternal(blindCast(d));
|
|
@@ -2123,15 +2140,33 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
2123
2140
|
namespaceId,
|
|
2124
2141
|
key: modelCoordinateKey(namespaceId, model.name)
|
|
2125
2142
|
}]));
|
|
2126
|
-
const
|
|
2143
|
+
const discriminatorFieldOf = (model, fieldName) => {
|
|
2127
2144
|
const field = modelNodes.get(model)?.fields.find((node) => node.fieldName === fieldName);
|
|
2128
|
-
if (field === void 0 || !("columnName" in field)
|
|
2145
|
+
if (field === void 0 || !("columnName" in field)) return {
|
|
2146
|
+
field: {
|
|
2147
|
+
ref: void 0,
|
|
2148
|
+
nullable: false,
|
|
2149
|
+
many: false,
|
|
2150
|
+
enumMembers: void 0
|
|
2151
|
+
},
|
|
2152
|
+
enumName: void 0
|
|
2153
|
+
};
|
|
2154
|
+
const handle = "enumTypeHandle" in field ? field.enumTypeHandle : void 0;
|
|
2155
|
+
const encoded = handle === void 0 ? void 0 : encodeEnumMembers(handle, input.codecLookup);
|
|
2129
2156
|
return {
|
|
2130
|
-
|
|
2131
|
-
|
|
2157
|
+
field: {
|
|
2158
|
+
ref: {
|
|
2159
|
+
codecId: field.descriptor.codecId,
|
|
2160
|
+
...ifDefined("typeParams", field.descriptor.typeParams === void 0 ? void 0 : blindCast(field.descriptor.typeParams))
|
|
2161
|
+
},
|
|
2162
|
+
nullable: field.nullable,
|
|
2163
|
+
many: field.many === true,
|
|
2164
|
+
enumMembers: encoded?.ok ? encoded.value.map(({ value }) => value) : void 0
|
|
2165
|
+
},
|
|
2166
|
+
enumName: handle?.enumName
|
|
2132
2167
|
};
|
|
2133
2168
|
};
|
|
2134
|
-
const { discriminatorDeclarations, baseDeclarations } = collectPolymorphismDeclarations(modelIdentities, input.symbolTable, input.sources, binder, specContextFor,
|
|
2169
|
+
const { discriminatorDeclarations, baseDeclarations, reported } = collectPolymorphismDeclarations(modelIdentities, input.symbolTable, input.sources, binder, specContextFor, discriminatorFieldOf, input.codecLookup, dataTypes, diagnostics);
|
|
2135
2170
|
const stiVariantKeys = /* @__PURE__ */ new Set();
|
|
2136
2171
|
for (const [variantKey, declaration] of baseDeclarations) if (!(getAttribute(declaration.model.attributes, "map") !== void 0)) stiVariantKeys.add(variantKey);
|
|
2137
2172
|
for (const variantKey of stiVariantKeys) {
|
|
@@ -2224,7 +2259,7 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
2224
2259
|
modelsByCoordinate[coordinate] = model;
|
|
2225
2260
|
}
|
|
2226
2261
|
const polyDiagnostics = createPslDiagnosticCollector(input.sources);
|
|
2227
|
-
const polymorphicModels = resolvePolymorphism(modelsByCoordinate, physicalNames, discriminatorDeclarations, baseDeclarations, syntheticPkFieldsByVariant, stiBaseFieldsByBase, polyDiagnostics);
|
|
2262
|
+
const polymorphicModels = resolvePolymorphism(modelsByCoordinate, physicalNames, discriminatorDeclarations, baseDeclarations, reported, syntheticPkFieldsByVariant, stiBaseFieldsByBase, polyDiagnostics);
|
|
2228
2263
|
if (polyDiagnostics.length > 0) return notOk({
|
|
2229
2264
|
summary: "PSL to SQL contract interpretation failed",
|
|
2230
2265
|
diagnostics: polyDiagnostics.toExternal()
|
|
@@ -2243,4 +2278,4 @@ function interpretPslDocumentToSqlContract(input) {
|
|
|
2243
2278
|
//#endregion
|
|
2244
2279
|
export { normalizeReferentialAction as a, interpretPslDocumentToSqlContract as i, buildEntityTypesByDiscriminator as n, indexFkRelations as r, applyBackrelationCandidates as t };
|
|
2245
2280
|
|
|
2246
|
-
//# sourceMappingURL=interpreter-
|
|
2281
|
+
//# sourceMappingURL=interpreter-BDpym-rc-BZVFp5GU.mjs.map
|