drawdb-io / drawdb-io/drawdb

[BUG] Importing DBML files doesn't preserve Ref keys(names)

Open
#1,033 0 comments 0 reactions 1 assignee Claimed by @1ilit View on GitHub
Dominant language
JavaScript
Stars
39.5k
Forks
3.2k
Avg merge
10h 46m
Merged PRs (30d)
16

Description

**Describe the bug**
I'm trying to import a DBML file where the refs are as follows:
```dbml
Table users [headercolor: #175e7a] {
id uuid [pk, default: `uuidv7()`]
}

Table user_sessions [headercolor: #175e7a] {
id uuid [pk, default: `uuidv7()`]
user_id uuid [not null]
}

Table addresses [headercolor: #175e7a] {
id uuid [pk, default: `uuidv7()`]
user_id uuid [not null]
}

Ref user_has_many_sessions {
user_sessions.user_id > users.id [delete: cascade, update: no action]
}

Ref user_has_many_addresses {
addresses.user_id > users.id [delete: cascade, update: no action]
}
```

or this:
```dbml
Table users [headercolor: #175e7a] {
id uuid [pk, default: `uuidv7()`]
}

Table user_sessions [headercolor: #175e7a] {
id uuid [pk, default: `uuidv7()`]
user_id uuid [not null]
}

Table addresses [headercolor: #175e7a] {
id uuid [pk, default: `uuidv7()`]
user_id uuid [not null]
}

Ref "user has many sessions" {
user_sessions.user_id > users.id [delete: cascade, update: no action]
}

Ref "user has many addresses" {
addresses.user_id > users.id [delete: cascade, update: no action]
}
```

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'File'
2. Click on 'Import from'
3. Select 'DBML'
4. Select the file

**Expected behavior**
I expect the tables to be drawn and the relationships name(key) to be persevered not overwritten with the default format of "fk_$foreignTableName_$foreignTableColumnName_$PrimaryTableName"

**Screenshots**

Image

**Desktop (please complete the following information):**
- OS:
```
Edition Windows 11 Pro
Version 25H2
OS build 26200.8457
Experience Windows Feature Experience Pack 1000.26100.304.0
```
- Browser Microsoft Edge Version 149.0.4022.52 (Official build) (64-bit)

**Additional context**
Here's the same markdown present in the issue above as files for the lazy ones

[tests.zip](https://github.com/user-attachments/files/28624450/tests.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.