Repository navigation
feat(erd): column markers for unique, not null, default and identity (#1277) - #1289
Merged
Merged
Conversation
…1277) ErdColumn gets isUnique, defaultValue and isIdentity, read by the catalog query of each dialect: - PostgreSQL: single-column unique indexes (not the PK), pg_attrdef defaults, attidentity or a nextval() default; - MySQL: column_key UNI, column_default, extra auto_increment; - SQLite: single-column unique indexes from pragma_index_list, dflt_value, INTEGER PRIMARY KEY (the rowid alias). A card row shows UQ / AI / DF after the type (nullable keeps its ?), its tooltip lists every fact one a line, the card is measured with them, and the SVG export prints them too. MCP describe_table reports unique, identity and default.
…ique Checked on a live database through MCP: user_specialties.user_id has 'UNIQUE (user_id) WHERE is_primary', one primary specialty per user, and was shown as unique. Only indexes without a predicate count now.
3 tasks
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.
Summary
Third issue of the ERD epic (#1286). A column showed only PK / FK; now it says what dbdiagram shows.
Catalog (
ErdColumngetsisUnique,defaultValue,isIdentity):pg_attrdefattidentity, or anextval()default (serial)column_key = 'UNI'column_defaultextrahasauto_incrementpragma_index_list)dflt_valueINTEGER PRIMARY KEY(the rowid alias)Old four- and five-column catalog rows still read, so fakes and callers that do not ask for the new columns keep working.
Card:
UQ/AI/DFafter the type; nullable keeps its?. The row's tooltip lists every fact, one a line (Default: 'new',Not null,Unique, ...). The card is measured with the markers; the SVG / PNG export prints them after the type.MCP:
describe_tablereportsunique,identityanddefault.Not done: composite unique constraints (only single-column ones count as "unique"); MySQL marks
UNIon the first column of a multi-column unique index too.Tests: catalog rows with and without the new columns; each dialect's SQL asks for them; the real SQLite catalog (through the MCP read-only session) reports unique, default and identity; a card shows the markers and the tooltip lists them.
Closes #1277
Test plan