@memberjunction/codegen-lib 6.1.0-edge.4 → 6.1.0-edge.6
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/README.md +20 -0
- package/dist/Angular/angular-codegen.d.ts +9 -6
- package/dist/Angular/angular-codegen.d.ts.map +1 -1
- package/dist/Angular/angular-codegen.js +80 -51
- package/dist/Angular/angular-codegen.js.map +1 -1
- package/dist/Angular/join-grid-related-entity-component.d.ts.map +1 -1
- package/dist/Angular/join-grid-related-entity-component.js +5 -2
- package/dist/Angular/join-grid-related-entity-component.js.map +1 -1
- package/dist/Angular/related-entity-components.d.ts +11 -0
- package/dist/Angular/related-entity-components.d.ts.map +1 -1
- package/dist/Angular/related-entity-components.js +23 -0
- package/dist/Angular/related-entity-components.js.map +1 -1
- package/dist/Angular/timeline-related-entity-component.d.ts.map +1 -1
- package/dist/Angular/timeline-related-entity-component.js +3 -2
- package/dist/Angular/timeline-related-entity-component.js.map +1 -1
- package/dist/Config/config.d.ts +216 -12
- package/dist/Config/config.d.ts.map +1 -1
- package/dist/Config/config.js +88 -6
- package/dist/Config/config.js.map +1 -1
- package/dist/Config/schema-output.d.ts +33 -0
- package/dist/Config/schema-output.d.ts.map +1 -0
- package/dist/Config/schema-output.js +52 -0
- package/dist/Config/schema-output.js.map +1 -0
- package/dist/Database/codeGenDatabaseProvider.d.ts +68 -1
- package/dist/Database/codeGenDatabaseProvider.d.ts.map +1 -1
- package/dist/Database/codeGenDatabaseProvider.js +142 -3
- package/dist/Database/codeGenDatabaseProvider.js.map +1 -1
- package/dist/Database/dbSchema.js +2 -1
- package/dist/Database/dbSchema.js.map +1 -1
- package/dist/Database/decision-metadata-format.d.ts +124 -0
- package/dist/Database/decision-metadata-format.d.ts.map +1 -0
- package/dist/Database/decision-metadata-format.js +279 -0
- package/dist/Database/decision-metadata-format.js.map +1 -0
- package/dist/Database/decision-metadata-writer.d.ts +48 -0
- package/dist/Database/decision-metadata-writer.d.ts.map +1 -0
- package/dist/Database/decision-metadata-writer.js +482 -0
- package/dist/Database/decision-metadata-writer.js.map +1 -0
- package/dist/Database/entity-field-change-tracking.d.ts +53 -0
- package/dist/Database/entity-field-change-tracking.d.ts.map +1 -0
- package/dist/Database/entity-field-change-tracking.js +120 -0
- package/dist/Database/entity-field-change-tracking.js.map +1 -0
- package/dist/Database/entity-level-tree-cycles.d.ts.map +1 -1
- package/dist/Database/entity-level-tree-cycles.js +3 -2
- package/dist/Database/entity-level-tree-cycles.js.map +1 -1
- package/dist/Database/exclude-tables.d.ts +26 -0
- package/dist/Database/exclude-tables.d.ts.map +1 -0
- package/dist/Database/exclude-tables.js +38 -0
- package/dist/Database/exclude-tables.js.map +1 -0
- package/dist/Database/field-metadata-lock.d.ts +47 -0
- package/dist/Database/field-metadata-lock.d.ts.map +1 -0
- package/dist/Database/field-metadata-lock.js +159 -0
- package/dist/Database/field-metadata-lock.js.map +1 -0
- package/dist/Database/manage-metadata.d.ts +142 -42
- package/dist/Database/manage-metadata.d.ts.map +1 -1
- package/dist/Database/manage-metadata.js +625 -287
- package/dist/Database/manage-metadata.js.map +1 -1
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts +2 -2
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts.map +1 -1
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js +90 -41
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js.map +1 -1
- package/dist/Database/providers/postgresql/metadataSupportObjects.js +31 -8
- package/dist/Database/providers/postgresql/metadataSupportObjects.js.map +1 -1
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts +3 -1
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts.map +1 -1
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js +58 -23
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js.map +1 -1
- package/dist/Database/providers/sqlserver/__tests__/BaseViewEmissionGoldenMaster.test.js +15 -2
- package/dist/Database/providers/sqlserver/__tests__/BaseViewEmissionGoldenMaster.test.js.map +1 -1
- package/dist/Database/providers/sqlserver/__tests__/SQLServerCodeGenProvider.test.js +17 -0
- package/dist/Database/providers/sqlserver/__tests__/SQLServerCodeGenProvider.test.js.map +1 -1
- package/dist/Database/sql_codegen.d.ts +24 -0
- package/dist/Database/sql_codegen.d.ts.map +1 -1
- package/dist/Database/sql_codegen.js +108 -29
- package/dist/Database/sql_codegen.js.map +1 -1
- package/dist/Manifest/GenerateClassRegistrationsManifest.d.ts +22 -0
- package/dist/Manifest/GenerateClassRegistrationsManifest.d.ts.map +1 -1
- package/dist/Manifest/GenerateClassRegistrationsManifest.js +115 -7
- package/dist/Manifest/GenerateClassRegistrationsManifest.js.map +1 -1
- package/dist/Misc/action_subclasses_codegen.js +2 -2
- package/dist/Misc/action_subclasses_codegen.js.map +1 -1
- package/dist/Misc/advanced_generation.d.ts +7 -5
- package/dist/Misc/advanced_generation.d.ts.map +1 -1
- package/dist/Misc/advanced_generation.js +34 -23
- package/dist/Misc/advanced_generation.js.map +1 -1
- package/dist/Misc/codegen-reporter.d.ts +5 -0
- package/dist/Misc/codegen-reporter.d.ts.map +1 -1
- package/dist/Misc/codegen-reporter.js +9 -2
- package/dist/Misc/codegen-reporter.js.map +1 -1
- package/dist/Misc/emit-stats.d.ts +28 -0
- package/dist/Misc/emit-stats.d.ts.map +1 -0
- package/dist/Misc/emit-stats.js +43 -0
- package/dist/Misc/emit-stats.js.map +1 -0
- package/dist/Misc/entity_subclasses_codegen.d.ts +20 -2
- package/dist/Misc/entity_subclasses_codegen.d.ts.map +1 -1
- package/dist/Misc/entity_subclasses_codegen.js +120 -51
- package/dist/Misc/entity_subclasses_codegen.js.map +1 -1
- package/dist/Misc/file-write.d.ts +15 -0
- package/dist/Misc/file-write.d.ts.map +1 -0
- package/dist/Misc/file-write.js +33 -0
- package/dist/Misc/file-write.js.map +1 -0
- package/dist/Misc/graphql_server_codegen.d.ts +12 -2
- package/dist/Misc/graphql_server_codegen.d.ts.map +1 -1
- package/dist/Misc/graphql_server_codegen.js +72 -16
- package/dist/Misc/graphql_server_codegen.js.map +1 -1
- package/dist/Misc/remote_operations_codegen.d.ts.map +1 -1
- package/dist/Misc/remote_operations_codegen.js +4 -3
- package/dist/Misc/remote_operations_codegen.js.map +1 -1
- package/dist/Misc/runCommand.d.ts +5 -0
- package/dist/Misc/runCommand.d.ts.map +1 -1
- package/dist/Misc/runCommand.js +43 -17
- package/dist/Misc/runCommand.js.map +1 -1
- package/dist/Misc/schema-emit.d.ts +123 -0
- package/dist/Misc/schema-emit.d.ts.map +1 -0
- package/dist/Misc/schema-emit.js +221 -0
- package/dist/Misc/schema-emit.js.map +1 -0
- package/dist/Misc/sql_logging.d.ts +63 -8
- package/dist/Misc/sql_logging.d.ts.map +1 -1
- package/dist/Misc/sql_logging.js +169 -42
- package/dist/Misc/sql_logging.js.map +1 -1
- package/dist/Misc/util.d.ts +12 -0
- package/dist/Misc/util.d.ts.map +1 -1
- package/dist/Misc/util.js +71 -8
- package/dist/Misc/util.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +28 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/runCodeGen.d.ts +20 -2
- package/dist/runCodeGen.d.ts.map +1 -1
- package/dist/runCodeGen.js +186 -33
- package/dist/runCodeGen.js.map +1 -1
- package/package.json +29 -29
|
@@ -400,7 +400,7 @@ export declare class PostgreSQLCodeGenProvider extends CodeGenDatabaseProvider {
|
|
|
400
400
|
routineParams: string;
|
|
401
401
|
};
|
|
402
402
|
/** @inheritdoc */
|
|
403
|
-
callRoutineSQL(schema: string, routineName: string, params: string[],
|
|
403
|
+
callRoutineSQL(schema: string, routineName: string, params: string[], paramNames?: string[], discardResult?: boolean): string;
|
|
404
404
|
/** @inheritdoc */
|
|
405
405
|
conditionalInsertSQL(checkQuery: string, insertSQL: string): string;
|
|
406
406
|
/** @inheritdoc */
|
|
@@ -487,7 +487,7 @@ export declare class PostgreSQLCodeGenProvider extends CodeGenDatabaseProvider {
|
|
|
487
487
|
*/
|
|
488
488
|
parseColumnDefaultValue(sqlDefaultValue: string): string | null;
|
|
489
489
|
/** @inheritdoc */
|
|
490
|
-
getPendingEntityFieldsSQL(mjCoreSchema: string, entityIDs?: string[]): string;
|
|
490
|
+
getPendingEntityFieldsSQL(mjCoreSchema: string, entityIDs?: string[], excludeSchemas?: string[]): string;
|
|
491
491
|
/** @inheritdoc */
|
|
492
492
|
getCheckConstraintsSchemaFilter(_excludeSchemas: string[]): string;
|
|
493
493
|
/** @inheritdoc */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSQLCodeGenProvider.d.ts","sourceRoot":"","sources":["../../../../src/Database/providers/postgresql/PostgreSQLCodeGenProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAyE,MAAM,sBAAsB,CAAC;AAE1I,OAAO,EACH,uBAAuB,EACvB,QAAQ,EACR,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EACnB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAqB,gBAAgB,EAAE,UAAU,EAA4H,MAAM,6BAA6B,CAAC;AAoBxN;;;;;;;;GAQG;AACH,qBACa,yBAA0B,SAAQ,uBAAuB;IAClE,kBAAkB;IAClB,IAAI,OAAO,IAAI,UAAU,CAExB;IAED,kBAAkB;IAClB,IAAI,WAAW,IAAI,gBAAgB,CAElC;IAED;;;;;;;;;;;;OAYG;IACG,eAAe,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA0ClD;;;;;;;;;;;;;;;;;OAiBG;IACM,kCAAkC,IAAI,OAAO;IAMtD;;;;OAIG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAoBlH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,gBAAgB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM;IAyN5D;;;;;;;;;OASG;IACM,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAG,MAAM;IAoBnH;;;;;;OAMG;IACM,kCAAkC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAMxG;;;;OAIG;IACM,kCAAkC,IAAI,MAAM;IAIrD;;;;;OAKG;IACM,sCAAsC,IAAI,MAAM;IAMzD;;;;;;;OAOG;IACH,OAAO,CAAC,6BAA6B;IAkBrC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;;;;;;OAOG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAapC;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IA4DjC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,yBAAyB;
|
|
1
|
+
{"version":3,"file":"PostgreSQLCodeGenProvider.d.ts","sourceRoot":"","sources":["../../../../src/Database/providers/postgresql/PostgreSQLCodeGenProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAyE,MAAM,sBAAsB,CAAC;AAE1I,OAAO,EACH,uBAAuB,EACvB,QAAQ,EACR,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EACnB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAqB,gBAA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EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAiBpE;;;;;OAKG;IACH,oCAAoC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAoBnG,kBAAkB;IAClB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAUzF;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IA8FrC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;OAGG;IACH,OAAO,CAAC,wCAAwC;CA2BnD"}
|
|
@@ -8,7 +8,7 @@ import { EntityInfo, ResolveStartupMode, SetProvider, StartupManager } from '@me
|
|
|
8
8
|
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
|
|
9
9
|
import { CodeGenDatabaseProvider, CRUDType, } from '../../codeGenDatabaseProvider.js';
|
|
10
10
|
import { configInfo, mj_core_schema } from '../../../Config/config.js';
|
|
11
|
-
import { logError, startSpinner, succeedSpinner } from '../../../Misc/status_logging.js';
|
|
11
|
+
import { logError, logWarning, startSpinner, succeedSpinner } from '../../../Misc/status_logging.js';
|
|
12
12
|
import { buildMetadataSupportObjectsSQL } from './metadataSupportObjects.js';
|
|
13
13
|
import { PostgreSQLDialect, AutoQuotePostgreSQLIdentifiers, restarLayeredOuterView, buildCreateOrReplaceLayeredOuterViewSQL, LayeredOuterRestarError } from '@memberjunction/sql-dialect';
|
|
14
14
|
import { shouldIncludeFieldInParams, useJsonArgShape, UserCache, } from '@memberjunction/generic-database-provider';
|
|
@@ -595,11 +595,22 @@ ${trigger}
|
|
|
595
595
|
const fnName = this.getCRUDRoutineName(entity, CRUDType.Create);
|
|
596
596
|
const viewName = this.getBaseViewName(entity);
|
|
597
597
|
const permissions = this.generateCRUDPermissions(entity, fnName, CRUDType.Create);
|
|
598
|
-
const
|
|
598
|
+
const isSingleKey = entity.PrimaryKeys.length === 1;
|
|
599
|
+
const firstKey = entity.FirstPrimaryKey; // first-pk-ok: read only for the UUID auto-generation strategy, which is gated on isSingleKey; every declaration, list and predicate below iterates entity.PrimaryKeys
|
|
599
600
|
const pkType = firstKey.Type.toLowerCase().trim();
|
|
600
|
-
const pkIsUuidSingle = (pkType === 'uniqueidentifier' || pkType === 'uuid') &&
|
|
601
|
-
|
|
602
|
-
|
|
601
|
+
const pkIsUuidSingle = (pkType === 'uniqueidentifier' || pkType === 'uuid') && isSingleKey;
|
|
602
|
+
// One plpgsql variable per key column. A single-column key keeps the historical `v_id`
|
|
603
|
+
// name; a composite key gets one variable per column so the INSERT lists every key
|
|
604
|
+
// column and the returning SELECT binds all of them (not just the first).
|
|
605
|
+
const pkVars = entity.PrimaryKeys.map((k) => ({
|
|
606
|
+
field: k,
|
|
607
|
+
varName: isSingleKey ? 'v_id' : `v_id_${k.CodeName}`,
|
|
608
|
+
pgType: this.mapSQLType(k.SQLFullType),
|
|
609
|
+
}));
|
|
610
|
+
const pkDeclarations = pkVars.map((v) => ` ${v.varName} ${v.pgType};`).join('\n');
|
|
611
|
+
const pkColListInit = pkVars.map((v) => `quote_ident('${v.field.Name.replace(/'/g, "''")}')`).join(" || ', ' || ");
|
|
612
|
+
const pkValListInit = pkVars.map((v) => `quote_literal(${v.varName}) || '::${v.pgType}'`).join(" || ', ' || ");
|
|
613
|
+
const pkWhere = pkVars.map((v) => `${pgDialect.QuoteIdentifier(v.field.Name)} = ${v.varName}`).join(' AND ');
|
|
603
614
|
// Writable fields participating in the INSERT — exclude PK (handled
|
|
604
615
|
// separately so we can supply a generated UUID when key is absent),
|
|
605
616
|
// exclude virtual / special-date / non-API-writable.
|
|
@@ -629,17 +640,17 @@ ${trigger}
|
|
|
629
640
|
const fieldNamesArrayLiteral = writableFields.map((f) => `'${f.Name}'`).join(', ');
|
|
630
641
|
// ID resolution body: differs by PK strategy. Single-UUID PK is auto-
|
|
631
642
|
// generated when the caller doesn't supply one; everything else (composite,
|
|
632
|
-
// non-UUID) requires the caller to provide
|
|
643
|
+
// non-UUID) requires the caller to provide every key column explicitly.
|
|
633
644
|
const idResolveBody = pkIsUuidSingle
|
|
634
645
|
? ` IF p_data ? '${firstKey.Name}' THEN
|
|
635
|
-
v_id := (p_data->>'${firstKey.Name}')::${
|
|
646
|
+
v_id := (p_data->>'${firstKey.Name}')::${this.mapSQLType(firstKey.SQLFullType)};
|
|
636
647
|
ELSE
|
|
637
648
|
v_id := gen_random_uuid();
|
|
638
649
|
END IF;`
|
|
639
|
-
: ` IF NOT (p_data ? '${
|
|
640
|
-
RAISE EXCEPTION '${fnName}: p_data must include "${
|
|
650
|
+
: pkVars.map((v) => ` IF NOT (p_data ? '${v.field.Name}') THEN
|
|
651
|
+
RAISE EXCEPTION '${fnName}: p_data must include "${v.field.Name}"';
|
|
641
652
|
END IF;
|
|
642
|
-
|
|
653
|
+
${v.varName} := (p_data->>'${v.field.Name}')::${v.pgType};`).join('\n');
|
|
643
654
|
return `
|
|
644
655
|
------------------------------------------------------------
|
|
645
656
|
----- CREATE FUNCTION FOR ${entity.BaseTable} (JSON-arg shape)
|
|
@@ -649,7 +660,7 @@ CREATE OR REPLACE FUNCTION ${pgDialect.QuoteSchema(entity.SchemaName, fnName)}(p
|
|
|
649
660
|
RETURNS SETOF ${pgDialect.QuoteSchema(entity.SchemaName, viewName)}
|
|
650
661
|
AS $$
|
|
651
662
|
DECLARE
|
|
652
|
-
|
|
663
|
+
${pkDeclarations}
|
|
653
664
|
v_field_name TEXT;
|
|
654
665
|
v_cast_expr TEXT;
|
|
655
666
|
v_col_list TEXT;
|
|
@@ -658,8 +669,8 @@ DECLARE
|
|
|
658
669
|
BEGIN
|
|
659
670
|
${idResolveBody}
|
|
660
671
|
|
|
661
|
-
v_col_list :=
|
|
662
|
-
v_val_list :=
|
|
672
|
+
v_col_list := ${pkColListInit};
|
|
673
|
+
v_val_list := ${pkValListInit};
|
|
663
674
|
|
|
664
675
|
-- Build column / value lists from keys present in p_data. Absent keys are
|
|
665
676
|
-- omitted entirely so the column's DEFAULT applies (matching the typed-arg
|
|
@@ -686,7 +697,7 @@ ${fieldCastEntries}
|
|
|
686
697
|
|
|
687
698
|
RETURN QUERY
|
|
688
699
|
SELECT * FROM ${pgDialect.QuoteSchema(entity.SchemaName, viewName)}
|
|
689
|
-
WHERE ${
|
|
700
|
+
WHERE ${pkWhere};
|
|
690
701
|
END;
|
|
691
702
|
$$ LANGUAGE plpgsql;
|
|
692
703
|
${permissions}
|
|
@@ -716,7 +727,10 @@ ${permissions}
|
|
|
716
727
|
const viewName = this.getBaseViewName(entity);
|
|
717
728
|
const paramString = this.generateCRUDParamString(entity.Fields, false);
|
|
718
729
|
const permissions = this.generateCRUDPermissions(entity, fnName, CRUDType.Create);
|
|
719
|
-
const firstKey = entity.FirstPrimaryKey;
|
|
730
|
+
const firstKey = entity.FirstPrimaryKey; // first-pk-ok: drives the single-key UUID strategy (guarded by PrimaryKeys.length === 1 in buildCreateInsertStrategy); identity and composite strategies iterate entity.PrimaryKeys
|
|
731
|
+
// v_new_id receives the database-generated key: the identity/serial column when there is
|
|
732
|
+
// one (which on a composite key need not be the first column), else the single UUID key.
|
|
733
|
+
const generatedKey = entity.PrimaryKeys.find((k) => k.AutoIncrement) ?? firstKey;
|
|
720
734
|
// For UUID PKs and AutoIncrement PKs, the strategy below adds the PK
|
|
721
735
|
// column manually (with v_new_id or RETURNING). Excluding it from the
|
|
722
736
|
// auto-generated insertColumns/insertValues avoids the column appearing
|
|
@@ -742,7 +756,7 @@ CREATE OR REPLACE FUNCTION ${pgDialect.QuoteSchema(entity.SchemaName, fnName)}(
|
|
|
742
756
|
${paramString}
|
|
743
757
|
) RETURNS SETOF ${pgDialect.QuoteSchema(entity.SchemaName, viewName)} AS $$
|
|
744
758
|
DECLARE
|
|
745
|
-
v_new_id ${this.mapSQLType(
|
|
759
|
+
v_new_id ${this.mapSQLType(generatedKey.SQLFullType)};
|
|
746
760
|
BEGIN
|
|
747
761
|
${strategy.preInsert}INSERT INTO ${pgDialect.QuoteSchema(entity.SchemaName, entity.BaseTable)}
|
|
748
762
|
(
|
|
@@ -1038,8 +1052,8 @@ WHERE ${ftsColName} IS NULL;
|
|
|
1038
1052
|
if (entity.PrimaryKeys.length !== 1) {
|
|
1039
1053
|
throw new Error(`[Hierarchy] Entity '${entity.Name}' has ${entity.PrimaryKeys.length} primary key fields. MemberJunction hierarchy TVF generation requires a single-column primary key.`);
|
|
1040
1054
|
}
|
|
1041
|
-
const primaryKey = entity.FirstPrimaryKey.Name;
|
|
1042
|
-
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType);
|
|
1055
|
+
const primaryKey = entity.FirstPrimaryKey.Name; // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1056
|
+
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType); // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1043
1057
|
const fieldName = field.Name;
|
|
1044
1058
|
const fnName = this.getHierarchyMetaFunctionName(entity, field);
|
|
1045
1059
|
return `
|
|
@@ -1104,8 +1118,8 @@ $$ LANGUAGE sql STABLE;
|
|
|
1104
1118
|
if (entity.PrimaryKeys.length !== 1) {
|
|
1105
1119
|
throw new Error(`[Hierarchy] Entity '${entity.Name}' has ${entity.PrimaryKeys.length} primary key fields. MemberJunction hierarchy TVF generation requires a single-column primary key.`);
|
|
1106
1120
|
}
|
|
1107
|
-
const primaryKey = entity.FirstPrimaryKey.Name;
|
|
1108
|
-
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType);
|
|
1121
|
+
const primaryKey = entity.FirstPrimaryKey.Name; // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1122
|
+
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType); // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1109
1123
|
const fieldName = field.Name;
|
|
1110
1124
|
const fnName = this.getDescendantsFunctionName(entity, field);
|
|
1111
1125
|
return `
|
|
@@ -1166,8 +1180,8 @@ $$ LANGUAGE sql STABLE;
|
|
|
1166
1180
|
if (entity.PrimaryKeys.length !== 1) {
|
|
1167
1181
|
throw new Error(`[Hierarchy] Entity '${entity.Name}' has ${entity.PrimaryKeys.length} primary key fields. MemberJunction hierarchy TVF generation requires a single-column primary key.`);
|
|
1168
1182
|
}
|
|
1169
|
-
const primaryKey = entity.FirstPrimaryKey.Name;
|
|
1170
|
-
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType);
|
|
1183
|
+
const primaryKey = entity.FirstPrimaryKey.Name; // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1184
|
+
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType); // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1171
1185
|
const fieldName = field.Name;
|
|
1172
1186
|
const fnName = this.getAncestorsFunctionName(entity, field);
|
|
1173
1187
|
return `
|
|
@@ -1244,7 +1258,7 @@ $$ LANGUAGE sql STABLE;
|
|
|
1244
1258
|
generateHierarchyFieldJoin(entity, field, alias) {
|
|
1245
1259
|
const fnName = this.getHierarchyMetaFunctionName(entity, field);
|
|
1246
1260
|
const tableAlias = entity.BaseTableCodeName.charAt(0).toLowerCase();
|
|
1247
|
-
return `LEFT JOIN LATERAL ${pgDialect.QuoteSchema(entity.SchemaName, fnName)}(${tableAlias}.${pgDialect.QuoteIdentifier(entity.FirstPrimaryKey.Name)}, ${tableAlias}.${pgDialect.QuoteIdentifier(field.Name)}) AS ${alias} ON true`;
|
|
1261
|
+
return `LEFT JOIN LATERAL ${pgDialect.QuoteSchema(entity.SchemaName, fnName)}(${tableAlias}.${pgDialect.QuoteIdentifier(entity.FirstPrimaryKey.Name)}, ${tableAlias}.${pgDialect.QuoteIdentifier(field.Name)}) AS ${alias} ON true`; // first-pk-ok: hierarchy TVF argument; sql_codegen.getHierarchyFKs skips composite-key entities and the TVF generator throws for them
|
|
1248
1262
|
}
|
|
1249
1263
|
/**
|
|
1250
1264
|
* Generates a PostgreSQL function that recursively calculates the root record ID for a
|
|
@@ -1254,8 +1268,8 @@ $$ LANGUAGE sql STABLE;
|
|
|
1254
1268
|
if (entity.PrimaryKeys.length !== 1) {
|
|
1255
1269
|
throw new Error(`[Hierarchy] Entity '${entity.Name}' has ${entity.PrimaryKeys.length} primary key fields. MemberJunction hierarchy TVF generation requires a single-column primary key.`);
|
|
1256
1270
|
}
|
|
1257
|
-
const primaryKey = entity.FirstPrimaryKey.Name;
|
|
1258
|
-
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType);
|
|
1271
|
+
const primaryKey = entity.FirstPrimaryKey.Name; // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1272
|
+
const primaryKeyType = this.mapSQLType(entity.FirstPrimaryKey.SQLFullType); // first-pk-ok: guarded by the PrimaryKeys.length !== 1 throw above; hierarchy TVFs are single-column by design
|
|
1259
1273
|
const fieldName = field.Name;
|
|
1260
1274
|
const fnName = this.getRootIDFunctionName(entity, field);
|
|
1261
1275
|
return `
|
|
@@ -1330,8 +1344,9 @@ $$ LANGUAGE sql STABLE;
|
|
|
1330
1344
|
generateRootFieldJoin(entity, field, alias) {
|
|
1331
1345
|
const fnName = this.getRootIDFunctionName(entity, field);
|
|
1332
1346
|
const tableAlias = entity.BaseTableCodeName.charAt(0).toLowerCase();
|
|
1347
|
+
const primaryKey = entity.FirstPrimaryKey.Name; // first-pk-ok: hierarchy TVF argument; sql_codegen.getHierarchyFKs skips composite-key entities and the TVF generator throws for them
|
|
1333
1348
|
return `LEFT JOIN LATERAL (
|
|
1334
|
-
SELECT ${pgDialect.QuoteSchema(entity.SchemaName, fnName)}(${tableAlias}.${pgDialect.QuoteIdentifier(
|
|
1349
|
+
SELECT ${pgDialect.QuoteSchema(entity.SchemaName, fnName)}(${tableAlias}.${pgDialect.QuoteIdentifier(primaryKey)}, ${tableAlias}.${pgDialect.QuoteIdentifier(field.Name)}) AS root_id
|
|
1335
1350
|
) AS ${alias} ON true`;
|
|
1336
1351
|
}
|
|
1337
1352
|
// ─── PERMISSIONS ─────────────────────────────────────────────────────
|
|
@@ -1604,9 +1619,15 @@ END $$;
|
|
|
1604
1619
|
}
|
|
1605
1620
|
// ─── METADATA MANAGEMENT: STORED PROCEDURE CALLS ─────────────────
|
|
1606
1621
|
/** @inheritdoc */
|
|
1607
|
-
callRoutineSQL(schema, routineName, params,
|
|
1622
|
+
callRoutineSQL(schema, routineName, params, paramNames, discardResult) {
|
|
1608
1623
|
const qualifiedName = pgDialect.QuoteSchema(schema, routineName);
|
|
1609
|
-
|
|
1624
|
+
let paramList;
|
|
1625
|
+
if (paramNames && paramNames.length === params.length) {
|
|
1626
|
+
paramList = params.map((p, i) => `p_${paramNames[i]} => ${p}`).join(', ');
|
|
1627
|
+
}
|
|
1628
|
+
else {
|
|
1629
|
+
paramList = params.join(', ');
|
|
1630
|
+
}
|
|
1610
1631
|
if (discardResult) {
|
|
1611
1632
|
// `SELECT * FROM routine(...)` is not universally valid on PostgreSQL: a function
|
|
1612
1633
|
// declared `RETURNS SETOF record` — which spDeleteEntityWithCoreDependencies is — is
|
|
@@ -1892,9 +1913,9 @@ $if_view_exists$;
|
|
|
1892
1913
|
}
|
|
1893
1914
|
// ─── METADATA MANAGEMENT: COMPLEX SQL GENERATION ─────────────────
|
|
1894
1915
|
/** @inheritdoc */
|
|
1895
|
-
getPendingEntityFieldsSQL(mjCoreSchema, entityIDs) {
|
|
1916
|
+
getPendingEntityFieldsSQL(mjCoreSchema, entityIDs, excludeSchemas) {
|
|
1896
1917
|
const qs = pgDialect.QuoteSchema.bind(pgDialect);
|
|
1897
|
-
return this.buildPendingEntityFieldsQuery(mjCoreSchema, qs, entityIDs);
|
|
1918
|
+
return this.buildPendingEntityFieldsQuery(mjCoreSchema, qs, entityIDs, excludeSchemas);
|
|
1898
1919
|
}
|
|
1899
1920
|
/** @inheritdoc */
|
|
1900
1921
|
getCheckConstraintsSchemaFilter(_excludeSchemas) {
|
|
@@ -2288,13 +2309,25 @@ WHERE p.prokind IN ('f', 'p')
|
|
|
2288
2309
|
buildCreateInsertStrategy(entity, firstKey, insertColumns, insertValues) {
|
|
2289
2310
|
const viewName = this.getBaseViewName(entity);
|
|
2290
2311
|
const pkCol = pgDialect.QuoteIdentifier(firstKey.Name);
|
|
2291
|
-
|
|
2312
|
+
const identityKey = entity.PrimaryKeys.find((k) => k.AutoIncrement);
|
|
2313
|
+
if (identityKey) {
|
|
2314
|
+
// Identity/serial key. On a composite key such as (TenantID, ID serial) the remaining key
|
|
2315
|
+
// columns are caller-supplied: they must be inserted and included in the row lookup. For a
|
|
2316
|
+
// single-column identity key callerSuppliedKeys is empty and nothing is added.
|
|
2317
|
+
const identityCol = pgDialect.QuoteIdentifier(identityKey.Name);
|
|
2318
|
+
const callerSuppliedKeys = entity.PrimaryKeys.filter((k) => !k.AutoIncrement);
|
|
2319
|
+
const keyColumns = callerSuppliedKeys.map((k) => pgDialect.QuoteIdentifier(k.Name)).join(',\n ');
|
|
2320
|
+
const keyValues = callerSuppliedKeys.map((k) => pgDialect.ParameterRef(k.CodeName)).join(',\n ');
|
|
2321
|
+
const keyPredicates = callerSuppliedKeys
|
|
2322
|
+
.map((k) => ` AND ${pgDialect.QuoteIdentifier(k.Name)} = ${pgDialect.ParameterRef(k.CodeName)}`)
|
|
2323
|
+
.join('');
|
|
2324
|
+
const hasNonPkColumns = insertColumns.trim().length > 0;
|
|
2292
2325
|
return {
|
|
2293
2326
|
preInsert: '',
|
|
2294
|
-
returningClause: `RETURNING ${
|
|
2295
|
-
selectClause: `SELECT * FROM ${pgDialect.QuoteSchema(entity.SchemaName, viewName)}\n WHERE ${
|
|
2296
|
-
finalColumns: insertColumns,
|
|
2297
|
-
finalValues: insertValues,
|
|
2327
|
+
returningClause: `RETURNING ${identityCol} INTO v_new_id`,
|
|
2328
|
+
selectClause: `SELECT * FROM ${pgDialect.QuoteSchema(entity.SchemaName, viewName)}\n WHERE ${identityCol} = v_new_id${keyPredicates}`,
|
|
2329
|
+
finalColumns: callerSuppliedKeys.length === 0 ? insertColumns : (hasNonPkColumns ? `${keyColumns},\n ${insertColumns}` : keyColumns),
|
|
2330
|
+
finalValues: callerSuppliedKeys.length === 0 ? insertValues : (hasNonPkColumns ? `${keyValues},\n ${insertValues}` : keyValues),
|
|
2298
2331
|
};
|
|
2299
2332
|
}
|
|
2300
2333
|
if ((firstKey.Type.toLowerCase().trim() === 'uniqueidentifier' || firstKey.Type.toLowerCase().trim() === 'uuid') && entity.PrimaryKeys.length === 1) {
|
|
@@ -2380,7 +2413,13 @@ WHERE p.prokind IN ('f', 'p')
|
|
|
2380
2413
|
return ` -- WARNING: Cannot cascade update ${relatedEntity.Name}.${fkField.Name} to NULL - entity does not allow updates`;
|
|
2381
2414
|
}
|
|
2382
2415
|
const updateFnName = this.getCRUDRoutineName(relatedEntity, CRUDType.Update);
|
|
2383
|
-
const
|
|
2416
|
+
const parentKey = this.resolveCascadeParentKeyField(parentEntity, fkField);
|
|
2417
|
+
if (!parentKey) {
|
|
2418
|
+
const warning = this.unresolvedCascadeKeyComment(parentEntity, relatedEntity, fkField);
|
|
2419
|
+
logWarning(`WARNING in ${this.getCRUDRoutineName(parentEntity, CRUDType.Delete)} generation: ${warning.trim()}`);
|
|
2420
|
+
return warning;
|
|
2421
|
+
}
|
|
2422
|
+
const whereClause = `${pgDialect.QuoteIdentifier(fkField.Name)} = ${pgDialect.ParameterRef(parentKey.CodeName)}`;
|
|
2384
2423
|
return ` -- Cascade: Set ${relatedEntity.Name}.${fkField.Name} to NULL
|
|
2385
2424
|
FOR v_rec IN
|
|
2386
2425
|
SELECT ${relatedEntity.PrimaryKeys.map((pk) => pgDialect.QuoteIdentifier(pk.Name)).join(', ')}
|
|
@@ -2400,7 +2439,13 @@ WHERE p.prokind IN ('f', 'p')
|
|
|
2400
2439
|
return ` -- WARNING: Cannot cascade delete ${relatedEntity.Name} records - entity does not allow deletes`;
|
|
2401
2440
|
}
|
|
2402
2441
|
const deleteFnName = this.getCRUDRoutineName(relatedEntity, CRUDType.Delete);
|
|
2403
|
-
const
|
|
2442
|
+
const parentKey = this.resolveCascadeParentKeyField(parentEntity, fkField);
|
|
2443
|
+
if (!parentKey) {
|
|
2444
|
+
const warning = this.unresolvedCascadeKeyComment(parentEntity, relatedEntity, fkField);
|
|
2445
|
+
logWarning(`WARNING in ${this.getCRUDRoutineName(parentEntity, CRUDType.Delete)} generation: ${warning.trim()}`);
|
|
2446
|
+
return warning;
|
|
2447
|
+
}
|
|
2448
|
+
const whereClause = `${pgDialect.QuoteIdentifier(fkField.Name)} = ${pgDialect.ParameterRef(parentKey.CodeName)}`;
|
|
2404
2449
|
return ` -- Cascade: Delete ${relatedEntity.Name} records via ${fkField.Name}
|
|
2405
2450
|
FOR v_rec IN
|
|
2406
2451
|
SELECT ${relatedEntity.PrimaryKeys.map((pk) => pgDialect.QuoteIdentifier(pk.Name)).join(', ')}
|
|
@@ -2486,12 +2531,15 @@ WHERE p.prokind IN ('f', 'p')
|
|
|
2486
2531
|
* Uses CTEs for FK, PK, and UK caches, then joins against entity metadata
|
|
2487
2532
|
* to find fields that exist in the database but not in MJ metadata.
|
|
2488
2533
|
*/
|
|
2489
|
-
buildPendingEntityFieldsQuery(schema, qs, entityIDs) {
|
|
2534
|
+
buildPendingEntityFieldsQuery(schema, qs, entityIDs, excludeSchemas) {
|
|
2490
2535
|
// PG uses lowercase UUIDs; entity IDs from the metadata cache are already
|
|
2491
2536
|
// normalized so direct string interpolation is safe (internal IDs, not user input).
|
|
2492
2537
|
const scopeFilter = entityIDs && entityIDs.length > 0
|
|
2493
2538
|
? `AND sf."EntityID" IN (${entityIDs.map(id => `'${id}'`).join(',')})`
|
|
2494
2539
|
: '';
|
|
2540
|
+
const schemaFilter = excludeSchemas && excludeSchemas.length > 0
|
|
2541
|
+
? `AND e."SchemaName" NOT IN (${excludeSchemas.map(s => `'${s.replace(/'/g, "''")}'`).join(',')})`
|
|
2542
|
+
: '';
|
|
2495
2543
|
return `
|
|
2496
2544
|
WITH fk_cache AS (
|
|
2497
2545
|
SELECT "column", "table", "schema_name", "referenced_table", "referenced_column", "referenced_schema"
|
|
@@ -2518,9 +2566,9 @@ numbered_rows AS (
|
|
|
2518
2566
|
SELECT
|
|
2519
2567
|
sf."EntityID",
|
|
2520
2568
|
COALESCE(ms."MaxSequence", 0) + 100000 + sf."Sequence" AS "Sequence",
|
|
2521
|
-
-- The RAW schema ordinal
|
|
2522
|
-
--
|
|
2523
|
-
--
|
|
2569
|
+
-- The RAW schema ordinal. The INSERT emitter uses it for DefaultInView only; the emitted
|
|
2570
|
+
-- Sequence is an apply-time MAX()+1 subquery. (Sequence above is only this query's ORDER BY
|
|
2571
|
+
-- key — never inserted — and the renumber pass overwrites every row from the schema.)
|
|
2524
2572
|
sf."Sequence" AS "SourceOrdinal",
|
|
2525
2573
|
sf."FieldName",
|
|
2526
2574
|
sf."Description",
|
|
@@ -2563,6 +2611,7 @@ numbered_rows AS (
|
|
|
2563
2611
|
WHERE
|
|
2564
2612
|
"EntityFieldID" IS NULL
|
|
2565
2613
|
${scopeFilter}
|
|
2614
|
+
${schemaFilter}
|
|
2566
2615
|
)
|
|
2567
2616
|
SELECT *
|
|
2568
2617
|
FROM numbered_rows
|