- Notifications
You must be signed in to change notification settings - Fork1k
feat(coderd/database): generate foreign key constraints and add database.IsForeignKeyViolation#9657
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
….IsForeignKeyViolation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
note: I haven't performed any DRY refactoring on this piece here; I figure de-duplication is premature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
💯 agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
(to be used in a follow-up PR)
👍
Uh oh!
There was an error while loading.Please reload this page.
name:="" | ||
switch { | ||
casestrings.Contains(query,"ALTER TABLE")&&strings.Contains(query,"ADD CONSTRAINT"): | ||
name=strings.Split(query," ")[6] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
parsing is pretty flimsy, but I guess the rest of the file is no better...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah... it works for the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't think it's worth improving, SQL is pretty stable 😄.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for adding this! ❤️
Uh oh!
There was an error while loading.Please reload this page.
I saw that we were generating this for unique constraints and thought it might be useful to add it for foreign keys as well (to be used in a follow-up PR)