Integration metadata can't declare descriptions on refresh, ExtendedType, joined fields or organic keys
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 18/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- sql, typescript
調査の方向性
This is four separate design changes across the schema builder and CodeGen, so pick one gap rather than the whole issue. Start by reading packages/Integration/schema-builder/src/SchemaBuilder.ts:109-129 and its DDLGenerator.ts:243 to see the evolution path, then IntegrationDiscoveryResolver.ts:2250-2854 for how metadata becomes table definitions, and manage-metadata.ts:6357-6425 for soft-FK application. Done means descriptions, ExtendedType, joined fields or organic keys survive both first create and refresh, verified against the rasa.io connector.
索引モデルが issue の本文から書いたものです。
説明
Summary
A connector's metadata (MJ: Integration Objects and MJ: Integration Object Fields) is the one place that knows what its data means: which column is an email, which ID links to which table, and how the same person shows up in several tables. Today little of that reaches the entities MJ builds from it, so every install needs hand work afterwards before the tables are useful to agents, queries and DBAutoDoc. Four gaps, all on next (d7a630ca9d):
- Descriptions reach the database only when a table is first created. A schema refresh never writes them.
- There is no way to set
ExtendedType(for exampleEmail) on a field from integration metadata. - Foreign keys from integration metadata never get a joined ("virtual") column from the related entity, and the link always targets the parent's first primary-key column.
- Integration metadata cannot declare organic keys.
In-process (RSU) CodeGen turns the AI generation steps off unless RSU_CODEGEN_ADVANCED_GENERATION=1 (packages/CodeGenLib/src/Config/config.ts:1774, ApplyInProcessAdvancedGenerationPolicy at 1789). That is a sensible default, but it means the only things set on an integration install are what the metadata states directly. The examples below use the rasa.io connector, whose tables (Contact, Newsletter Contact, Newsletter Action, Contact External Identifier, topics) all link to one contact ID that carries the email.
1. Descriptions don't reach existing installs
On first create, IntegrationObject.Description and IntegrationObjectField.Description flow through the resolver (packages/MJServer/src/resolvers/IntegrationDiscoveryResolver.ts:2250, :2287, :2827) into the table definition, and the create DDL writes MS_Description / COMMENT ON for the table and each column (packages/SchemaEngine/src/DDLGenerator.ts:156, GenerateDescriptions at 169). CodeGen then copies those into Entity.Description and EntityField.Description, and keeps them in sync while AutoUpdateDescription is on.
A table that already exists takes the evolution path instead (packages/Integration/schema-builder/src/SchemaBuilder.ts:109-129). SchemaEvolution.GenerateEvolutionMigration and GenerateAlterTableAddColumn (packages/Integration/schema-builder/src/DDLGenerator.ts:243) only add or alter columns and indexes. Neither writes a description. So:
- a column added by a later connector version has no description;
- a description improved in a later connector version never reaches the database or the entity.
Suggested fix: in the evolution path, emit CommentOnColumn for added columns, and update the table and column comments when the catalog text differs from the current extended property. CodeGen's existing AutoUpdateDescription sync then carries it to the entity, and a description someone edited by hand in MJ stays protected by that flag.
2. No way to set ExtendedType from integration metadata
MJIntegrationObjectFieldSchema (packages/MJCoreEntities/src/generated/schemas/__mj.ts:26598) has no ExtendedType and no IsNameField, and neither does the per-connection MJCompanyIntegrationObjectFieldSchema (:13812). Nothing under packages/Integration or packages/SchemaEngine references ExtendedType, and TargetColumnConfig (packages/Integration/schema-builder/src/interfaces.ts:61-80) has nowhere to carry it.
The only CodeGen step that sets EntityField.ExtendedType is the AI form-layout pass, which is off under RSU and only touches new fields. A connector that knows email is an email address has no way to say so. Today the customer sets ExtendedType='Email' and AutoUpdateExtendedType=0 on each field by hand after install, and features that look for email fields (list builders that need an "emailable" entity, for example) don't see these tables until then.
Suggested fix: let an Integration Object Field declare ExtendedType, carry it through TargetColumnConfig into the per-field additionalSchemaInfo entry, and have CodeGen apply it the same way it applies other declared field settings (respecting AutoUpdateExtendedType).
3. Joined fields for integration foreign keys
RelatedIntegrationObjectID becomes a soft FK, but:
- The target column is never the one the metadata names. The resolver hardcodes
TargetField: 'ID'(IntegrationDiscoveryResolver.ts:2854), andSoftFKConfigEmitterlinks to the parent's first primary-key column (packages/Integration/schema-builder/src/SoftFKConfigEmitter.ts:152).RelatedIntegrationObjectFieldNameis ignored. For a parent with a two-column key (rasa's Newsletter Contact isnewsletter_id + id), a child is silently linked tonewsletter_idalone, and any join on it multiplies rows. - The link never gets a joined column. CodeGen sets
IncludeRelatedEntityNameFieldInBaseViewonly when it inserts a field that already has a hard FK (packages/CodeGenLib/src/Database/manage-metadata.ts:7009). Integration columns are inserted before soft FKs are applied, and the soft-FK update (applySoftForeignKeys,:6357, update at about:6419-6425) doesn't set the flag. The base view only joins fields with that flag or aRelatedEntityJoinFieldsconfig (packages/CodeGenLib/src/Database/sql_codegen.ts:3918). - Even with the flag on, the alias would collide for snake_case keys:
stripIDstrips only an uppercaseIDsuffix (sql_codegen.ts:4090-4095), socontact_idmaps to itself and the column becomescontact_id_Virtual.
The case that matters is a single-column link to a unique target, for example contact_id on an action or topics table pointing at Contact.id. With a joined email column on each of those tables, the email is one column away instead of a hand-written join. EntityField.RelatedEntityJoinFields ({"mode":"override","fields":[{"field":"email","alias":"ContactEmail"}]}) already does exactly this, but only as a setting made by hand after install.
Suggested fix:
- Honor
RelatedIntegrationObjectFieldNameas the FK target, and refuse (with a warning) a link to one column of a multi-column key instead of linking to the first PK column. - Let an Integration Object Field declare the joined fields for its link (same shape as
RelatedEntityJoinFields), and write that onto the EntityField when the soft FK is applied. - Make
stripIDhandle a_id/_IDsuffix.
4. Organic keys can't be declared
Organic keys (MJ: Entity Organic Keys, MJ: Entity Organic Key Related Entities) are created by CodeGen from an OrganicKeys array in additionalSchemaInfo (extractOrganicKeysFromConfig, manage-metadata.ts:1206; processOrganicKeyConfig, :1330).
The integration schema builder never writes that array. Its table entries carry only PrimaryKey and ForeignKeys (SoftFKConfigEmitter.ts:8-17). The closest thing, IsUniqueKey on a non-key field, becomes OrganicKeyFields (SchemaBuilder.ts:315), which only produces an index IX_<schema>_<table>_OK_<col> (packages/SchemaEngine/src/DDLGenerator.ts:123-129) and no organic key rows.
DBAutoDoc doesn't fill the gap here. It doesn't read ExtendedType, and it drops a detected concept unless one of its columns is a primary key (packages/DBAutoDoc/src/discovery/OrganicKeyTranslator.ts), so an email that is never a key column isn't proposed. The connector knows the answer up front ("email on Contact identifies a person, and it matches email on these other tables"), and it should be able to say so.
Suggested fix: let an Integration Object declare organic keys (name, match fields, normalization such as LowerCaseTrim, related objects and their fields), and have the schema builder translate them into OrganicKeys entries for the tables it builds, using the derived schema and table names. CodeGen's existing processing does the rest.
Suggested shape
One option that needs no new columns: a documented block in the existing Configuration JSON on Integration Object Field and Integration Object, for example:
// Integration Object Field: Contact.email
{ "entityField": { "ExtendedType": "Email" } }
// Integration Object Field: Newsletter Action.contact_id
{ "entityField": { "RelatedEntityJoinFields": { "mode": "override", "fields": [{ "field": "email", "alias": "ContactEmail" }] } } }
// Integration Object: Contact
{ "organicKeys": [{ "Name": "Email", "MatchFieldNames": ["email"], "NormalizationStrategy": "LowerCaseTrim",
"RelatedObjects": [{ "Object": "Newsletter Contact", "FieldNames": ["email"] }] }] }
New columns (ExtendedType on Integration Object Field, for example) would work as well and are easier to validate. Either way, the important part is that the schema builder passes these through on both first create and refresh.
Related, smaller
- Shipped queries: a connector can already ship approved
MJ: Queriesin its metadata. They have to take the schema as a parameter ({{ IntegrationSchema | default('rasa') | sqlIdentifier }}), because nothing resolves an integration's table toschema.viewat run time, and a query shipped before its tables exist isn't re-extracted after the apply. A run-time token for an integration's schema, or re-extraction after apply, would make these simpler. Integration/docs/schema-management.mdsays the generated views include joins for related records. Per #3 they don't for integration FKs; the doc should match whichever behavior ships.
- 主要言語
- TSQL
- スター
- 32
- フォーク
- 7
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 504
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MemberJunction/MJ のほかの issue
-
DBAutoDoc: export --state-file writes SQL Server SQL for a PostgreSQL database, ignoring --providerオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
MemberJunction/MJ#7094 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
MemberJunction/MJ#6971 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MemberJunction/MJ#6947 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MemberJunction/MJ#6800 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MemberJunction/MJ#6746 ·
メンテナーはふだん 1 日以内に返信
MemberJunction/MJ の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OHDSI/Data2Evidence#3815 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
roc-lang/basic-webserver#277 ·
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
redhat-developer/rhdh-plugin-export-overlays#4995 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
fidelity
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hosts対応中かも @huanghaoyuanhhy が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
zilliztech/milvus-backup#1418 ·
メンテナーはふだん 1 日以内に返信