feat(dbml): @postgres/@sqlite dialect directives (#19) #27
Merged
warkanum
merged 1 commits from 2026-09-08 14:19:03 +00:00
issue-19-dbml-directives into master
No Reviewers
Labels
Clear labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Low
4
The priority is low
Priority
Medium
3
The priority is medium
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
No labels
Milestone
No items
No Milestone
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: wdevs/relspecgo#27
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Implements #19.
What
Adds parseable
@<namespace>[(<target>)]: <args>directives that can be embedded in DBML files to carry dialect-specific features (partitioning,WITHOUT ROWID, tablespaces, index storage parameters, identity columns, collations, …). Directives are:Metadata,DBML → model → DBMLround-trip (idempotent output),@postgres:never appears in SQLite output and vice-versa).Grammar & locations
@<namespace>[(<column>)]: <args>— namespace^[a-z][a-z0-9_]*$, args verbatim, key = lowercased first token.Table {(col)targetindexes { }Repeatable by default; catalog "singleton" keys error on a second occurrence at the same location. All errors are line-numbered.
Translation
PostgreSQL:
PARTITION BY/INHERITS/WITH/TABLESPACE(table),STORAGE/COMPRESSION/GENERATED … AS IDENTITY(column),WITH/TABLESPACE(index) — hooked into both CREATE TABLE paths and both index-generation paths.SQLite:
WITHOUT ROWID/STRICT(table options),COLLATE(column).Strict mode
New
--strict-directivesflag (ReaderOptions/WriterOptions): reader errors on unknown namespace/key; each writer errors on an untranslatable key for its own dialect and always ignores other dialects.Also fixed
A preexisting DBML parser bug where an
indexes { }closing brace was mistaken for end-of-table, dropping any trailing table-level content (Note:, and now directives).Docs & tests
docs/DBML_DIRECTIVES.md+ sections in the DBML reader/writer and pgsql/sqlite writer READMEs.directives_test.goinpkg/models,pkg/readers/dbml,pkg/writers/{dbml,pgsql,sqlite}.go build,go test ./...,make lintall pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ss2MY5J11cRGwEz86ZXk7d
Add parseable `@<namespace>[(<target>)]: <args>` directives embedded in DBML. They are stored losslessly on each object's Metadata, round-trip unchanged through the DBML writer, and are translated to SQL only by the writer for the matching dialect. - models: Directive type + catalog; Metadata map added to Column and Index - dbml reader: parse and attach directives at database/table/column/index level; line-numbered errors; repeatable by default with singleton duplicate detection. Fixes a preexisting bug where an `indexes {}` closing brace ended the table early, dropping trailing Note: and directive lines. - dbml writer: re-emit directives at their location; idempotent output - pgsql writer: PARTITION BY / INHERITS / WITH / TABLESPACE (table), STORAGE / COMPRESSION / identity (column), WITH / TABLESPACE (index) - sqlite writer: WITHOUT ROWID / STRICT (table), COLLATE (column) - --strict-directives flag on ReaderOptions and WriterOptions - docs/DBML_DIRECTIVES.md + reader/writer READMEs Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ss2MY5J11cRGwEz86ZXk7d