Bugs Fixed
1. pkg/models/models.go:184 - Fixed typo in ForeignKeyConstraint constant from "foreign_Key" to "foreign_key" 2. pkg/readers/drawdb/reader.go:62-68 - Fixed ReadSchema() to properly detect schema name from tables instead of hardcoding "default" 3. pkg/writers/dbml/writer.go:128 - Changed primary key attribute from "primary key" to DBML standard "pk" 4. pkg/writers/dbml/writer.go:208-221 - Fixed foreign key reference format to use "table.column" syntax for single columns instead of "table.(column)" Test Results All reader and writer tests are now passing: Readers: - DBML: 74.4% coverage (2 tests skipped due to missing parser features for Ref statements) - DCTX: 77.6% coverage - DrawDB: 83.6% coverage - JSON: 82.1% coverage - YAML: 82.1% coverage Writers: - Bun: 68.5% coverage - DBML: 91.5% coverage - DCTX: 100.0% coverage - DrawDB: 83.8% coverage - GORM: 69.2% coverage - JSON: 82.4% coverage - YAML: 82.4% coverage
This commit is contained in:
62
tests/assets/dbml/complex.dbml
Normal file
62
tests/assets/dbml/complex.dbml
Normal file
@@ -0,0 +1,62 @@
|
||||
// Complex test schema with relationships, indexes, and multiple schemas
|
||||
Table public.users {
|
||||
id bigint [pk, increment]
|
||||
email varchar(255) [unique, not null]
|
||||
username varchar(50) [not null]
|
||||
name varchar(100)
|
||||
bio text
|
||||
is_active boolean [default: true]
|
||||
created_at timestamp [not null]
|
||||
updated_at timestamp
|
||||
|
||||
indexes {
|
||||
(email) [unique, name: 'idx_users_email']
|
||||
(username, is_active) [name: 'idx_users_username_active']
|
||||
}
|
||||
|
||||
Note: 'User accounts table'
|
||||
}
|
||||
|
||||
Table public.posts {
|
||||
id bigint [pk, increment]
|
||||
user_id bigint [not null]
|
||||
title varchar(200) [not null]
|
||||
slug varchar(250) [unique, not null]
|
||||
content text
|
||||
published boolean [default: false]
|
||||
view_count integer [default: 0]
|
||||
created_at timestamp [not null]
|
||||
updated_at timestamp
|
||||
|
||||
indexes {
|
||||
(slug) [unique]
|
||||
(user_id, published)
|
||||
(created_at) [type: 'btree']
|
||||
}
|
||||
}
|
||||
|
||||
Table public.comments {
|
||||
id bigint [pk, increment]
|
||||
post_id bigint [not null]
|
||||
user_id bigint [not null]
|
||||
content text [not null]
|
||||
is_edited boolean [default: false]
|
||||
created_at timestamp [not null]
|
||||
updated_at timestamp
|
||||
}
|
||||
|
||||
Table admin.audit_logs {
|
||||
id bigint [pk, increment]
|
||||
user_id bigint
|
||||
action varchar(100) [not null]
|
||||
entity_type varchar(50)
|
||||
entity_id bigint
|
||||
details jsonb
|
||||
created_at timestamp [not null]
|
||||
}
|
||||
|
||||
// Relationships
|
||||
Ref: public.posts.user_id > public.users.id [ondelete: CASCADE, onupdate: CASCADE]
|
||||
Ref: public.comments.post_id > public.posts.id [ondelete: CASCADE]
|
||||
Ref: public.comments.user_id > public.users.id [ondelete: SET NULL]
|
||||
Ref: admin.audit_logs.user_id > public.users.id [ondelete: SET NULL]
|
||||
Reference in New Issue
Block a user