Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code generation creates duplicate foreign key constraints #13

Open
hugoalopez-dtu opened this issue Apr 3, 2022 · 0 comments
Open

Code generation creates duplicate foreign key constraints #13

hugoalopez-dtu opened this issue Apr 3, 2022 · 0 comments
Labels
bug Problems related to bugs
Milestone

Comments

@hugoalopez-dtu
Copy link

Take the following erd source:

entity Doctors{
DoctorId: string key
name: string
}

entity Patients{
PatientId: string key
name: string
}

entity Tests{
TestId: string key
name: string
}

relationship Treats{
Doctors[N] -> Patients[N]
}

relationship Log{
Patients[1] -> Tests[N]
}


The SQL scripts generated contain the following error:

ERROR 1826 (HY000): Duplicate foreign key constraint name 'fk_PatientId'

This is because, in order to implement Treats and Log, we need to create constraints on the fly, but they need to be unique. A possibility is to add a random salt generator in order to make relationships unique, or, probably simpler, adding the relationship name as part of the constraint to avoid duplicates.

@borkdominik borkdominik added the bug Problems related to bugs label Apr 5, 2022
@plglaser plglaser assigned plglaser and unassigned plglaser Aug 5, 2022
@plglaser plglaser added this to the v0.1.0 milestone Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Problems related to bugs
Projects
None yet
Development

No branches or pull requests

3 participants