@memberjunction/codegen-lib 5.32.0 → 5.34.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.
Files changed (70) hide show
  1. package/README.md +24 -0
  2. package/dist/Config/config.d.ts +19 -8
  3. package/dist/Config/config.d.ts.map +1 -1
  4. package/dist/Config/config.js +18 -8
  5. package/dist/Config/config.js.map +1 -1
  6. package/dist/Config/db-connection.d.ts.map +1 -1
  7. package/dist/Config/db-connection.js +8 -3
  8. package/dist/Config/db-connection.js.map +1 -1
  9. package/dist/Database/codeGenDatabaseProvider.d.ts +67 -0
  10. package/dist/Database/codeGenDatabaseProvider.d.ts.map +1 -1
  11. package/dist/Database/codeGenDatabaseProvider.js +82 -15
  12. package/dist/Database/codeGenDatabaseProvider.js.map +1 -1
  13. package/dist/Database/manage-metadata.d.ts +112 -4
  14. package/dist/Database/manage-metadata.d.ts.map +1 -1
  15. package/dist/Database/manage-metadata.js +347 -43
  16. package/dist/Database/manage-metadata.js.map +1 -1
  17. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.d.ts +4 -0
  18. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.d.ts.map +1 -1
  19. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.js +6 -0
  20. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.js.map +1 -1
  21. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts +122 -16
  22. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts.map +1 -1
  23. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js +605 -49
  24. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js.map +1 -1
  25. package/dist/Database/providers/postgresql/viewFallback.d.ts +14 -0
  26. package/dist/Database/providers/postgresql/viewFallback.d.ts.map +1 -1
  27. package/dist/Database/providers/postgresql/viewFallback.js +107 -13
  28. package/dist/Database/providers/postgresql/viewFallback.js.map +1 -1
  29. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.d.ts +4 -0
  30. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.d.ts.map +1 -1
  31. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.js +6 -0
  32. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.js.map +1 -1
  33. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts +5 -2
  34. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts.map +1 -1
  35. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js +27 -7
  36. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js.map +1 -1
  37. package/dist/Database/providers/sqlserver/__tests__/SQLServerCodeGenProvider.test.js +101 -0
  38. package/dist/Database/providers/sqlserver/__tests__/SQLServerCodeGenProvider.test.js.map +1 -1
  39. package/dist/Database/sql.d.ts +8 -0
  40. package/dist/Database/sql.d.ts.map +1 -1
  41. package/dist/Database/sql.js +18 -14
  42. package/dist/Database/sql.js.map +1 -1
  43. package/dist/Database/sql_codegen.d.ts +19 -5
  44. package/dist/Database/sql_codegen.d.ts.map +1 -1
  45. package/dist/Database/sql_codegen.js +109 -55
  46. package/dist/Database/sql_codegen.js.map +1 -1
  47. package/dist/Misc/action_subclasses_codegen.js +1 -1
  48. package/dist/Misc/action_subclasses_codegen.js.map +1 -1
  49. package/dist/Misc/createNewUser.d.ts.map +1 -1
  50. package/dist/Misc/createNewUser.js +14 -3
  51. package/dist/Misc/createNewUser.js.map +1 -1
  52. package/dist/Misc/entity_subclasses_codegen.d.ts.map +1 -1
  53. package/dist/Misc/entity_subclasses_codegen.js +23 -17
  54. package/dist/Misc/entity_subclasses_codegen.js.map +1 -1
  55. package/dist/Misc/graphql_server_codegen.d.ts +11 -0
  56. package/dist/Misc/graphql_server_codegen.d.ts.map +1 -1
  57. package/dist/Misc/graphql_server_codegen.js +27 -40
  58. package/dist/Misc/graphql_server_codegen.js.map +1 -1
  59. package/dist/Misc/sql_logging.d.ts.map +1 -1
  60. package/dist/Misc/sql_logging.js +22 -2
  61. package/dist/Misc/sql_logging.js.map +1 -1
  62. package/dist/Misc/system_integrity.js +3 -3
  63. package/dist/Misc/system_integrity.js.map +1 -1
  64. package/dist/Misc/temp_batch_file.js +2 -2
  65. package/dist/Misc/temp_batch_file.js.map +1 -1
  66. package/dist/runCodeGen.d.ts +1 -1
  67. package/dist/runCodeGen.d.ts.map +1 -1
  68. package/dist/runCodeGen.js +51 -6
  69. package/dist/runCodeGen.js.map +1 -1
  70. package/package.json +19 -18
@@ -1 +1 @@
1
- {"version":3,"file":"sql_codegen.d.ts","sourceRoot":"","sources":["../../src/Database/sql_codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAkC,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAK7G,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAmD,iBAAiB,EAAyB,MAAM,2BAA2B,CAAC;AAI/J,OAAO,EAAsB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAUvE,eAAO,MAAM,MAAM;;;;CAIP,CAAC;AAEb,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;AA0CxD,qBAAa,cAAc;IACvB,SAAS,CAAC,iBAAiB,EAAE,cAAc,CAAkF;IAC7H,IAAW,gBAAgB,IAAI,cAAc,CAE5C;IAED;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAA4C;IAC1F,IAAW,UAAU,IAAI,uBAAuB,CAE/C;IACD,IAAW,UAAU,CAAC,KAAK,EAAE,uBAAuB,EAEnD;IAED;;OAEG;IACH,SAAS,CAAC,sCAAsC,EAAE,MAAM,EAAE,CAAM;IAEhE;;OAEG;IACH,SAAS,CAAC,sCAAsC,EAAE,OAAO,CAAS;IAElE;;;;OAIG;IACH,SAAS,CAA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AKG;cACa,kCAAkC,CAC9C,IAAI,EAAE,iBAAiB,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC;IAYnB;;;OAGG;IACH,SAAS,CAAC,gCAAgC,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAyCpE;;;OAGG;cACa,8BAA8B,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCrF;;;OAGG;cACa,gCAAgC,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAgCtG;;;OAGG;cACa,6CAA6C,CACzD,IAAI,EAAE,iBAAiB,EACvB,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAgBvB;;;OAGG;cACa,wCAAwC,CACpD,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,UAAU,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;IAoDhB;;;;;;;;OAQG;IACH,SAAS,CAAC,2BAA2B,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE;CA8EzG"}
@@ -4,7 +4,6 @@ import * as fs from 'fs';
4
4
  import path from 'path';
5
5
  import { SQLUtilityBase } from './sql.js';
6
6
  import { CodeGenDatabaseProvider } from './codeGenDatabaseProvider.js';
7
- import { SQLServerCodeGenProvider } from './providers/sqlserver/SQLServerCodeGenProvider.js';
8
7
  import { autoIndexForeignKeys, configInfo, customSqlScripts, mjCoreSchema } from '../Config/config.js';
9
8
  import { ManageMetadataBase } from './manage-metadata.js';
10
9
  import { UserCache } from '@memberjunction/sqlserver-dataprovider';
@@ -22,44 +21,20 @@ export const SPType = {
22
21
  * databases. The base class implements support for SQL Server. In future versions of MJ, we will break out an abstract base class that has the skeleton of the logic and then the SQL Server version will be a sub-class
23
22
  * of that abstract base class and other databases will be sub-classes of the abstract base class as well.
24
23
  */
25
- /**
26
- * Creates the appropriate CodeGen database provider based on the configured database type.
27
- * Falls back to SQLServerCodeGenProvider for backward compatibility.
28
- *
29
- * @param dbType The database platform type from configuration
30
- * @returns A CodeGenDatabaseProvider instance for the specified platform
31
- */
32
- function createCodeGenProvider(dbType) {
33
- switch (dbType) {
34
- case 'postgresql':
35
- // Dynamic import is avoided - the PostgreSQL provider should be
36
- // registered via MJGlobal ClassFactory for proper decoupling.
37
- // For now, attempt to resolve from ClassFactory.
38
- try {
39
- const pgProvider = MJGlobal.Instance.ClassFactory.CreateInstance(CodeGenDatabaseProvider, 'PostgreSQLCodeGenProvider');
40
- if (pgProvider) {
41
- return pgProvider;
42
- }
43
- }
44
- catch {
45
- // Fall through to error
46
- }
47
- throw new Error('PostgreSQL CodeGen provider not found. Ensure @memberjunction/postgresql-dataprovider ' +
48
- 'is installed and its CodeGen provider is registered before running CodeGen.');
49
- case 'mssql':
50
- default:
51
- return new SQLServerCodeGenProvider();
52
- }
53
- }
54
24
  export class SQLCodeGenBase {
55
25
  constructor() {
56
26
  this._sqlUtilityObject = MJGlobal.Instance.ClassFactory.CreateInstance(SQLUtilityBase);
57
27
  /**
58
- * The database-specific code generation provider. Defaults to SQL Server.
59
- * Override this property or set it before calling generation methods to use
60
- * a different database platform (e.g., PostgreSQL).
28
+ * The database-specific code generation provider, resolved from
29
+ * `MJGlobal.ClassFactory` against the configured `dbPlatform`. Each provider
30
+ * (`SQLServerCodeGenProvider`, `PostgreSQLCodeGenProvider`, …) registers
31
+ * itself with `@RegisterClass(CodeGenDatabaseProvider, '<platform>')` —
32
+ * the canonical {@link DatabasePlatform} value as its key — so this
33
+ * single line picks up the right one without dialect-specific branching.
34
+ * Subclasses can override via `@RegisterClass(... priority)` to plug in
35
+ * customized codegen behavior, same hook every other MJ class uses.
61
36
  */
62
- this._dbProvider = createCodeGenProvider(configInfo.dbType);
37
+ this._dbProvider = MJGlobal.Instance.ClassFactory.CreateInstance(CodeGenDatabaseProvider, configInfo.dbPlatform);
63
38
  /**
64
39
  * Array of entity names that qualify for forced regeneration based on the whereClause filter
65
40
  */
@@ -132,8 +107,10 @@ export class SQLCodeGenBase {
132
107
  // ALWAYS use the first filter where we only include entities that have IncludeInAPI = 1
133
108
  // Entities are already sorted by name in PostProcessEntityMetadata (see providerBase.ts)
134
109
  const baselineEntities = entities.filter(e => e.IncludeInAPI);
135
- const includedEntities = baselineEntities.filter(e => configInfo.excludeSchemas.find(s => s.toLowerCase() === e.SchemaName.toLowerCase()) === undefined); //only include entities that are NOT in the excludeSchemas list
136
- const excludedEntities = baselineEntities.filter(e => configInfo.excludeSchemas.find(s => s.toLowerCase() === e.SchemaName.toLowerCase()) !== undefined); //only include entities that ARE in the excludeSchemas list in this array
110
+ // OPTIMIZATION: Use a Set for O(1) lookups instead of O(n) array finds to improve performance
111
+ const excludeSchemasSet = new Set(configInfo.excludeSchemas.map(s => s.toLowerCase()));
112
+ const includedEntities = baselineEntities.filter(e => !excludeSchemasSet.has(e.SchemaName.toLowerCase())); //only include entities that are NOT in the excludeSchemas list
113
+ const excludedEntities = baselineEntities.filter(e => excludeSchemasSet.has(e.SchemaName.toLowerCase())); //only include entities that ARE in the excludeSchemas list in this array
137
114
  // Initialize temp batch files for each schema
138
115
  // These will be populated as SQL is generated and will be used for actual execution
139
116
  const schemas = Array.from(new Set(baselineEntities.map(e => e.SchemaName))).sort();
@@ -170,6 +147,40 @@ export class SQLCodeGenBase {
170
147
  // complete picture of what's missing — partial generation is
171
148
  // strictly more useful than nothing.
172
149
  let entityGenSuccess = true;
150
+ // Build a UNION will-regenerate set across every batch we're about
151
+ // to launch (main + cascade-regen + excluded-perms). The PG view
152
+ // fallback's restoreDependents path uses this to skip restoring
153
+ // captured dependents that codegen will recreate later in the run.
154
+ // Without the union, batch 1's fallback only sees batch 1's
155
+ // entities — so a dependent like vwAIAgentRuns (which lives in
156
+ // batch 2 cascade-regen) is "missing from willRegenerate", the
157
+ // fallback tries to restore its stale captured definition, and
158
+ // that definition references views (vwTestRuns, vwRecordChanges)
159
+ // that no longer exist post-CASCADE → restore-view fails.
160
+ // Empty BaseView fields are filtered so virtual/no-view entities
161
+ // don't add `__mj.` (a malformed key) to the set.
162
+ const allBatchEntities = [
163
+ ...entitiesWithoutCascadeRegeneration,
164
+ ...entitiesForCascadeRegeneration,
165
+ ...excludedEntities,
166
+ ];
167
+ const globalWillRegenerate = new Set(allBatchEntities
168
+ .filter(e => !!e.BaseView)
169
+ .map(e => `${e.SchemaName}.${e.BaseView}`));
170
+ // PostgreSQL must serialize per-entity processing. Each PG entity's
171
+ // phased execution (view → CRUD → permissions) issues
172
+ // CREATE OR REPLACE VIEW with a 42P16 fallback that does
173
+ // capture/DROP CASCADE/CREATE/restore via pg_depend. Running this
174
+ // in parallel against entities with cross-references (e.g.
175
+ // vwAIModels ←→ vwAIModelVendors, view + dependent function) hits
176
+ // catalog-level deadlocks ("ERROR: deadlock detected") and the
177
+ // deadlock victim's transaction rolls back leaving its dependents
178
+ // dropped but never recreated — net effect: 11+ views silently
179
+ // missing after one codegen run, then the next run crashes during
180
+ // AI Engine init because vwAIModels is gone. SQL Server doesn't
181
+ // hit this because its execution path is bulk-monolithic, not
182
+ // phased per-entity.
183
+ const perEntityBatchSize = configInfo.dbPlatform === 'postgresql' ? 1 : 5;
173
184
  // Generate SQL for entities that don't need cascade delete regeneration
174
185
  const genResult = await this.generateAndExecuteEntitySQLToSeparateFiles({
175
186
  pool,
@@ -180,8 +191,9 @@ export class SQLCodeGenBase {
180
191
  // other dialects defer to the bulk step 2(e) below.
181
192
  skipExecution: perEntitySkipExecution,
182
193
  writeFiles: true,
183
- batchSize: 5,
184
- enableSQLLoggingForNewOrModifiedEntities: true
194
+ batchSize: perEntityBatchSize,
195
+ enableSQLLoggingForNewOrModifiedEntities: true,
196
+ willRegenerate: globalWillRegenerate
185
197
  }); // enable sql logging for NEW entities....
186
198
  if (!genResult.Success) {
187
199
  logError('Main entity SQL generation batch had failures — continuing with cascade-regen and excluded-perms batches; validator will report any missing routines.');
@@ -198,7 +210,8 @@ export class SQLCodeGenBase {
198
210
  skipExecution: perEntitySkipExecution,
199
211
  writeFiles: true,
200
212
  batchSize: 1, // Process sequentially to maintain dependency order
201
- enableSQLLoggingForNewOrModifiedEntities: true
213
+ enableSQLLoggingForNewOrModifiedEntities: true,
214
+ willRegenerate: globalWillRegenerate
202
215
  });
203
216
  if (!cascadeGenResult.Success) {
204
217
  logError('Cascade-regen batch had failures — continuing; validator will report any missing routines.');
@@ -214,9 +227,10 @@ export class SQLCodeGenBase {
214
227
  directory,
215
228
  onlyPermissions: true,
216
229
  skipExecution: true, // skip execution because we execute it all in a giant batch below
217
- batchSize: 5,
230
+ batchSize: perEntityBatchSize,
218
231
  writeFiles: true,
219
- enableSQLLoggingForNewOrModifiedEntities: false /*don't log this stuff, it is just permissions for excluded entities*/
232
+ enableSQLLoggingForNewOrModifiedEntities: false, /*don't log this stuff, it is just permissions for excluded entities*/
233
+ willRegenerate: globalWillRegenerate
220
234
  });
221
235
  if (!genResult2.Success) {
222
236
  logError('Excluded-entities permissions batch had failures — continuing; validator will report any missing routines.');
@@ -445,8 +459,15 @@ export class SQLCodeGenBase {
445
459
  try {
446
460
  await pool.query(fileContents);
447
461
  }
448
- catch (e) {
449
- logError(`Error executing permissions file ${fullPath} for entity ${e.Name}: ${e}`);
462
+ catch (sqlError) {
463
+ // Don't shadow the outer `e` (EntityInfo) — the inner `catch (e)`
464
+ // would otherwise rebind `e` to the SQL error, making
465
+ // `e.Name` resolve to the error's `.Name` (undefined for pg
466
+ // errors) instead of the entity's name. That's why downstream
467
+ // logs read `for entity undefined` and were impossible to
468
+ // pin to a specific entity.
469
+ const errorMessage = sqlError instanceof Error ? sqlError.message : String(sqlError);
470
+ logError(`Error executing permissions file ${fullPath} for entity ${e.Name}: ${errorMessage}`);
450
471
  innerSuccess = false;
451
472
  }
452
473
  }
@@ -485,11 +506,13 @@ export class SQLCodeGenBase {
485
506
  try {
486
507
  const failedEntities = [];
487
508
  const totalEntities = options.entities.length;
488
- // Build the will-regenerate set once per batch. A dialect phased
489
- // executor (e.g. PG) uses this to skip restoring dependents that
490
- // are about to be rebuilt with new definitions — avoids stale
491
- // captured definitions conflicting with newly-regenerated targets.
492
- const willRegenerate = new Set(options.entities.map(e => `${e.SchemaName}.${e.BaseView}`));
509
+ // Prefer the caller-supplied union (across all batches in this run)
510
+ // when available; fall back to a per-batch set for callers that
511
+ // don't pass one. The per-batch set is too narrow when an earlier
512
+ // batch's CASCADE drops a view owned by a later batch — the
513
+ // captured-dependent-restore fails because it doesn't know that
514
+ // dependent will be re-emitted in a subsequent batch.
515
+ const willRegenerate = options.willRegenerate ?? new Set(options.entities.map(e => `${e.SchemaName}.${e.BaseView}`));
493
516
  for (let i = 0; i < totalEntities; i += options.batchSize) {
494
517
  const batch = options.entities.slice(i, i + options.batchSize);
495
518
  const promises = batch.map(async (e) => {
@@ -1389,7 +1412,13 @@ export class SQLCodeGenBase {
1389
1412
  sOutput += sOutput == '' ? '' : '\n';
1390
1413
  const qi = this._dbProvider.Dialect.QuoteIdentifier.bind(this._dbProvider.Dialect);
1391
1414
  const qs = this._dbProvider.Dialect.QuoteSchema.bind(this._dbProvider.Dialect);
1392
- const relatedTable = ef._RelatedEntityNameFieldIsVirtual ? ef.RelatedEntityBaseView : ef.RelatedEntityBaseTable;
1415
+ // Computed/generated columns are physically present in the base table, so we
1416
+ // can join directly to the base table even when IsVirtual=1. Only route
1417
+ // through the view for genuinely view-only columns (IsVirtual=1, IsComputed=0).
1418
+ // Joining to the base table avoids unnecessary view materialization and
1419
+ // sidesteps the self-reference problem when the FK is a self-FK.
1420
+ const useView = ef._RelatedEntityNameFieldIsVirtual && !ef._RelatedEntityNameFieldIsComputed;
1421
+ const relatedTable = useView ? ef.RelatedEntityBaseView : ef.RelatedEntityBaseTable;
1393
1422
  sOutput += `${ef.AllowsNull ? 'LEFT OUTER' : 'INNER'} JOIN\n ${qs(ef.RelatedEntitySchemaName, relatedTable)} AS ${ef._RelatedEntityTableAlias}\n ON\n ${qi(classNameFirstChar)}.${qi(ef.Name)} = ${ef._RelatedEntityTableAlias}.${qi(ef.RelatedEntityFieldName)}`;
1394
1423
  }
1395
1424
  }
@@ -1502,11 +1531,28 @@ export class SQLCodeGenBase {
1502
1531
  }
1503
1532
  ef._RelatedEntityJoinFieldMappings = [];
1504
1533
  let anyFieldIsVirtual = false;
1534
+ let anyFieldIsComputed = false;
1505
1535
  // 1. Handle NameField (if not overridden)
1506
1536
  // In 'extend' mode: include the NameField (backward compatible with IncludeRelatedEntityNameFieldInBaseView)
1507
1537
  // In 'override' mode: skip the NameField, only use explicitly configured fields
1508
1538
  if (config.mode !== 'override' && ef.IncludeRelatedEntityNameFieldInBaseView) {
1509
- const { nameField, nameFieldIsVirtual } = this.getIsNameFieldForSingleEntity(ef.RelatedEntity);
1539
+ const { nameField, nameFieldIsVirtual, nameFieldIsComputed } = this.getIsNameFieldForSingleEntity(ef.RelatedEntity);
1540
+ // Self-FK + view-only NameField + dialect that can't handle self-join → skip.
1541
+ // A view-only column (IsVirtual=1, IsComputed=0) can only be read from the
1542
+ // view, so the join must target the view; but PG's strict `CREATE OR REPLACE
1543
+ // VIEW` parser raises 42P01 on a body that LEFT-JOINs the view-being-created
1544
+ // to itself, and SQL Server's parse-time name resolution fails the same way
1545
+ // post-DROP. Skipping drops the virtual lookup column from the view.
1546
+ //
1547
+ // For computed/generated columns (IsVirtual=1, IsComputed=1), the column is
1548
+ // physically in the base table — the join target is the base table (not the
1549
+ // view) — so the self-reference issue doesn't apply and we DON'T skip.
1550
+ const isSelfFK = ef.RelatedEntityID && ef.EntityID && ef.RelatedEntityID.toLowerCase() === ef.EntityID.toLowerCase();
1551
+ if (nameField !== '' && nameFieldIsVirtual && !nameFieldIsComputed && isSelfFK && !this._dbProvider.canSelfJoinViewForVirtualNameField()) {
1552
+ const owningEntity = md.Entities.find(e => UUIDsEqual(e.ID, ef.EntityID));
1553
+ logStatus(` Skipping self-referential view-only NameField join for ${owningEntity?.Name ?? ef.EntityID}.${ef.Name} (dialect: ${this._dbProvider.PlatformKey})`);
1554
+ continue;
1555
+ }
1510
1556
  if (nameField !== '') {
1511
1557
  // only add to the output, if we found a name field for the related entity.
1512
1558
  ef._RelatedEntityTableAlias = ef.RelatedEntityClassName + '_' + ef.Name;
@@ -1528,11 +1574,14 @@ export class SQLCodeGenBase {
1528
1574
  ef._RelatedEntityJoinFieldMappings.push({
1529
1575
  sourceField: nameField,
1530
1576
  alias: safeAlias,
1531
- isVirtual: nameFieldIsVirtual
1577
+ isVirtual: nameFieldIsVirtual,
1578
+ isComputed: nameFieldIsComputed
1532
1579
  });
1533
1580
  allGeneratedAliases.push(safeAlias);
1534
1581
  if (nameFieldIsVirtual)
1535
1582
  anyFieldIsVirtual = true;
1583
+ if (nameFieldIsComputed)
1584
+ anyFieldIsComputed = true;
1536
1585
  // check to see if the database already knows about the RelatedEntityNameFieldMap or not
1537
1586
  if (ef.RelatedEntityNameFieldMap === null ||
1538
1587
  ef.RelatedEntityNameFieldMap === undefined ||
@@ -1563,24 +1612,29 @@ export class SQLCodeGenBase {
1563
1612
  logError(`RelatedEntityJoinFields: Alias '${alias}' for field '${fieldName}' would collide with an existing field or alias in entity '${currentEntity.Name}'`);
1564
1613
  continue;
1565
1614
  }
1566
- // Get field metadata from related entity to check if virtual
1615
+ // Get field metadata from related entity to check if virtual / computed
1567
1616
  const relatedEntity = md.EntityByName(ef.RelatedEntity);
1568
1617
  const relatedField = relatedEntity?.Fields.find(f => f.Name.toLowerCase() === fieldName.toLowerCase());
1569
1618
  const isVirtual = relatedField?.IsVirtual || false;
1619
+ const isComputed = relatedField?.IsComputed || false;
1570
1620
  ef._RelatedEntityJoinFieldMappings.push({
1571
1621
  sourceField: fieldName,
1572
1622
  alias: alias,
1573
- isVirtual: isVirtual
1623
+ isVirtual: isVirtual,
1624
+ isComputed: isComputed
1574
1625
  });
1575
1626
  allGeneratedAliases.push(alias);
1576
1627
  if (isVirtual)
1577
1628
  anyFieldIsVirtual = true;
1629
+ if (isComputed)
1630
+ anyFieldIsComputed = true;
1578
1631
  }
1579
1632
  }
1580
1633
  // 3. Generate SQL for the mappings
1581
1634
  if (ef._RelatedEntityJoinFieldMappings.length > 0) {
1582
1635
  ef._RelatedEntityTableAlias = ef.RelatedEntityClassName + '_' + ef.Name;
1583
1636
  ef._RelatedEntityNameFieldIsVirtual = anyFieldIsVirtual;
1637
+ ef._RelatedEntityNameFieldIsComputed = anyFieldIsComputed;
1584
1638
  for (const mapping of ef._RelatedEntityJoinFieldMappings) {
1585
1639
  const qi = this._dbProvider.Dialect.QuoteIdentifier.bind(this._dbProvider.Dialect);
1586
1640
  sOutput += `${fieldCount === 0 ? '' : ','}\n ${ef._RelatedEntityTableAlias}.${qi(mapping.sourceField)} AS ${qi(mapping.alias)}`;
@@ -1596,11 +1650,11 @@ export class SQLCodeGenBase {
1596
1650
  if (e) {
1597
1651
  const ef = e.NameField;
1598
1652
  if (e.NameField)
1599
- return { nameField: ef.Name, nameFieldIsVirtual: ef.IsVirtual };
1653
+ return { nameField: ef.Name, nameFieldIsVirtual: ef.IsVirtual, nameFieldIsComputed: ef.IsComputed === true };
1600
1654
  }
1601
1655
  else
1602
1656
  logStatus(`ERROR: Could not find entity with name ${entityName}`);
1603
- return { nameField: '', nameFieldIsVirtual: false };
1657
+ return { nameField: '', nameFieldIsVirtual: false, nameFieldIsComputed: false };
1604
1658
  }
1605
1659
  stripID(name) {
1606
1660
  if (name.endsWith('ID'))