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:
118
tests/assets/json/database.json
Normal file
118
tests/assets/json/database.json
Normal file
@@ -0,0 +1,118 @@
|
||||
{
|
||||
"name": "test_db",
|
||||
"description": "Test database for JSON reader",
|
||||
"database_type": "pgsql",
|
||||
"schemas": [
|
||||
{
|
||||
"name": "public",
|
||||
"tables": [
|
||||
{
|
||||
"name": "users",
|
||||
"schema": "public",
|
||||
"description": "User accounts table",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "bigint",
|
||||
"not_null": true,
|
||||
"auto_increment": true,
|
||||
"is_primary_key": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"not_null": true,
|
||||
"comment": "User email address"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "varchar",
|
||||
"length": 100,
|
||||
"not_null": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "timestamp",
|
||||
"not_null": true,
|
||||
"default": "CURRENT_TIMESTAMP"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"idx_users_email": {
|
||||
"name": "idx_users_email",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"columns": ["email"],
|
||||
"unique": true,
|
||||
"type": "btree"
|
||||
}
|
||||
},
|
||||
"constraints": {},
|
||||
"relationships": {}
|
||||
},
|
||||
{
|
||||
"name": "posts",
|
||||
"schema": "public",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"table": "posts",
|
||||
"schema": "public",
|
||||
"type": "bigint",
|
||||
"not_null": true,
|
||||
"auto_increment": true,
|
||||
"is_primary_key": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"table": "posts",
|
||||
"schema": "public",
|
||||
"type": "bigint",
|
||||
"not_null": true
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"table": "posts",
|
||||
"schema": "public",
|
||||
"type": "varchar",
|
||||
"length": 200,
|
||||
"not_null": true
|
||||
},
|
||||
"content": {
|
||||
"name": "content",
|
||||
"table": "posts",
|
||||
"schema": "public",
|
||||
"type": "text",
|
||||
"not_null": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"constraints": {
|
||||
"fk_posts_user": {
|
||||
"name": "fk_posts_user",
|
||||
"type": "foreign_key",
|
||||
"table": "posts",
|
||||
"schema": "public",
|
||||
"columns": ["user_id"],
|
||||
"referenced_table": "users",
|
||||
"referenced_schema": "public",
|
||||
"referenced_columns": ["id"],
|
||||
"on_delete": "CASCADE",
|
||||
"on_update": "CASCADE"
|
||||
}
|
||||
},
|
||||
"relationships": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
31
tests/assets/json/schema.json
Normal file
31
tests/assets/json/schema.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "public",
|
||||
"description": "Public schema",
|
||||
"tables": [
|
||||
{
|
||||
"name": "users",
|
||||
"schema": "public",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "bigint",
|
||||
"not_null": true,
|
||||
"is_primary_key": true
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "varchar",
|
||||
"length": 50,
|
||||
"not_null": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"constraints": {},
|
||||
"relationships": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
27
tests/assets/json/table.json
Normal file
27
tests/assets/json/table.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "users",
|
||||
"schema": "public",
|
||||
"description": "Users table",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "bigint",
|
||||
"not_null": true,
|
||||
"auto_increment": true,
|
||||
"is_primary_key": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"table": "users",
|
||||
"schema": "public",
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"not_null": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"constraints": {},
|
||||
"relationships": {}
|
||||
}
|
||||
Reference in New Issue
Block a user