Feature: allow to infer logical links between tables - #28
Merged
Conversation
Infer references from <table>_id columns when --add-logical-references is enabled. Match qualified tables within their schema, support singular and plural table names, preserve explicit references, and skip ambiguous targets. Cover logical reference inference, skipped tables, ordering, and idempotency.
Load explicit YAML mappings through --logical-references-file and apply them before optional column-name inference. Validate all configured endpoints, reject conflicting targets without partial changes, and ignore exact duplicates. Expose parsing and schema-application APIs, document the file format with an example, and cover YAML decoding and reference validation behavior.
Add optional reference names to the schema and YAML mappings. Name inferred references as "logical <column>" and render names as diagram relationship labels while retaining existing labels for unnamed references. Document the naming behavior and update target golden fixtures and tests.
denchenko
requested changes
Aug 4, 2026
Recognize common -es plural suffixes when deriving singular table aliases, including doubled-z plurals. Cover address, box, dish, quiz, and watch logical-reference inference with regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds logical-reference support for schemas whose intended
relationships are not completely represented by database foreign keys.
Adds
--add-logical-referencesto infer references from<table>_idsourcecolumns. Inference is opt-in, stays within the same schema qualifier, supports
common singular/plural table names, skips ambiguous matches, and never replaces
an existing database or configured reference.
Adds
--logical-references-filefor explicitly declared YAML mappings. Eachmapping identifies full source and target table-column endpoints, is validated
against the extracted schema, and is applied after
--skip-tablesbut beforeoptional automatic inference. Invalid endpoints or conflicting targets fail the
command without partially changing the schema; exact duplicate mappings are
ignored.
Adds an optional
namefield to logical references. Inferred links default tological <source-column>, while YAML mappings may supply a descriptive label.Names are exposed in JSON and rendered as relationship labels in D2, PlantUML,
and Mermaid; unnamed references retain their existing output labels.
Documents the YAML format and naming behavior, provides a copyable example,
and updates schema and renderer golden-test coverage.
P.S. Yes, these are "AI assisted" changes ))