Merged
Conversation
For a composite reference, the foreign fields have to be checked against the parent fields for type equality. The parent field are found by searching the parent Entity, using 'getFD'. For the foreign fields,though, this is unecessary. Currently, for each composite field, we extract its fields name and search again for the same field using 'getFd'. This creates an unecessary round trip.
This required a small tweak to TH. This is because when the primary key is autogenerated it has an extra layer. So when TH defines a function :: ChildFields -> ParentKey, we need an extra unwrapping.
The `References` keyword can be omitted to have backwords compatibility. The fields before and after the key word must have the same length (and are type checked as before).
TH needed a small tweak, because the function ChildFields -> ParentKey can't be generated when we reference manual fields. This is just a utility function and missing it in this case shouldn't create any issues.
Tests for this are missing because there is not yet postgres support.
Nullable references are currently broken, since TH generates code which doesn't compile. The tests in this commit provide a good workaround to make this case work properly.
This was
linked to
issues
Oct 31, 2020
parsonsmatt
commented
Oct 31, 2020
| , cDefaultConstraintName = Nothing | ||
| , cMaxLen = Nothing | ||
| , cReference = ref | ||
| -- TODO: Fix cascade reference is ignored |
parsonsmatt
commented
Oct 31, 2020
| a | ||
| [name] | ||
| (Util.dbIdColumnsEsc escape refdef) | ||
| -- TODO: Fix cascade reference is ignored |
Collaborator
Author
There was a problem hiding this comment.
seems like we can just copy it on down
parsonsmatt
commented
Oct 31, 2020
| Right _ -> | ||
| SqlType' SqlString | ||
| Left (Just FTKeyCon) -> | ||
| SqlType' SqlString |
Collaborator
Author
There was a problem hiding this comment.
this seems extremely dubious to me
Collaborator
Author
|
@erikd y'all wanna take a look at this? |
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.
Before submitting your PR, check that you've:
@sincedeclarations to the HaddockAfter submitting your PR:
(unreleased)on the ChangelogContinuation of #1121
Fixes #957