Can't generate DBML with a database having many-to-many relation
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 233
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
When I try to generate DBML for a database with a many-to-many relation, it fails with:
```
Cannot read properties of undefined (reading 'fieldIds')
```
Here is a reproduction code:
```js
const content = `Table users {
id int [pk]
}
Table projects {
id int [pk]
}
Ref: projects.id <> users.id // many-to-many
`
const db: Database = (new Parser(undefined)).parse(content, 'dbmlv2')
const res = ModelExporter.export(db, 'dbml', false)
```
The error is on the last line.
I also tried with a few variations:
- use `'dbml'` format instead of `'dbmlv2'`
- replace the last line with `ModelExporter.export(db.normalize(), 'dbml', true)`
- inline relation (`id int [pk, ref: <> users.id]`)
They all fail the same.
If I remove the many-to-many relation, it works well.
Am I doing something bad?
Contributor guide
Assessment
This issue has not been assessed yet.