Fix multiple fk issue with PostgreSQL migrations#1010
Merged
MaxGabriel merged 5 commits intoyesodweb:masterfrom Jan 11, 2020
Merged
Fix multiple fk issue with PostgreSQL migrations#1010MaxGabriel merged 5 commits intoyesodweb:masterfrom
MaxGabriel merged 5 commits intoyesodweb:masterfrom
Conversation
robbassi
commented
Jan 8, 2020
| refMap = Map.fromList $ foldl ref [] cols | ||
| where ref rs c = case cReference c of | ||
| Nothing -> rs | ||
| (Just r) -> (unDBName $ cName c, r) : rs |
Contributor
Author
There was a problem hiding this comment.
Here we build a map of column names to foreign keys, so we can pass that on to getColumn.
robbassi
commented
Jan 8, 2020
| ,"AND kcu.table_name=? " | ||
| ,"AND kcu.column_name=?"] | ||
| ,"AND kcu.column_name=? " | ||
| ,"AND tc.constraint_name=?"] |
Contributor
Author
There was a problem hiding this comment.
We now use the reference name to filter the query.
Contributor
Author
|
Tests seem to be failing for |
Member
|
Looks like newer versions of the |
Collaborator
|
Try merging master - there's an upper bound in place to prevent the cabal solver from picking that version. |
06fceec to
feb00e6
Compare
This commit adds a (failing) test case for when multiple foreign key constraints exist on a single column.
Contributor
Author
|
@parsonsmatt thanks! |
parsonsmatt
approved these changes
Jan 10, 2020
Collaborator
parsonsmatt
left a comment
There was a problem hiding this comment.
Looks great to me. Thanks!
| , T.unpack (unDBName cname) | ||
| , " but got: " | ||
| , show xs | ||
| ] |
Collaborator
There was a problem hiding this comment.
❤️ great error message!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #1009 for the PostgreSQL backend. In order to support multiple foreign keys on a single column, we now pass the reference name to
getColumn, and use it in the where clause when querying foreign keys for the column.Before submitting your PR, check that you've:
After submitting your PR: