-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
Ensure integrity of columns with foreign key constraints applied #973
Comments
Is this meant to be a validation step? |
I'm not sure what you mean. |
If we change the datatype of a foreign key, I think it will cause an error, so I am not sure where this scenario would occur. Will it be a validation we do on the service layer before it gets to the database since the database won't allow this anyway |
It's not possible to break the link by altering column type. It's disallowed at the database level, and would return an error. There are some constrained situations where type alterations are allowed, but not in ways that create problems. For performance and flexibility, I suggest letting the user make the request, and presenting a "nice" version of the error if it's disallowed by the database. This would allow, for example, altering the foreign key column and the column it references to a |
@silentninja @mathemancer This is just a requirement from the product side, I did not consider whether the database allowed this or not when creating this ticket. If the DB doesn't allow it, handling this should just be creating the proper exception and error code and showing it in the API. |
@kgodey Would you be okay with altering types whenever it wouldn't break the link? I.e., when it creates no error at the DB layer? |
@mathemancer Yup, that's fine. |
In that case, I suggest just using the default DB behavior and handling errors gracefully. |
This issue has not been updated in 90 days and is being marked as stale. |
Closing this, too old, requirements are likely out of date. We can create a new issue if we need this functionality in the future. |
Problem
Users may try to change the data type of columns with foreign key constraints applied, which may break the foreign key.
Solution
The API should not allow the data type of a column with a foreign key constraint to be changed.
The text was updated successfully, but these errors were encountered: