Skip to content

Conversation

@parsonsmatt
Copy link
Collaborator

@parsonsmatt parsonsmatt commented Oct 30, 2020

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Bumped the version number if there isn't an (unreleased) on the Changelog
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

Continuation of #1121

Fixes #957

kderme and others added 15 commits October 30, 2020 12:53
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.
, cDefaultConstraintName = Nothing
, cMaxLen = Nothing
, cReference = ref
-- TODO: Fix cascade reference is ignored
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this is available here

a
[name]
(Util.dbIdColumnsEsc escape refdef)
-- TODO: Fix cascade reference is ignored
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we can just copy it on down

Right _ ->
SqlType' SqlString
Left (Just FTKeyCon) ->
SqlType' SqlString
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems extremely dubious to me

@parsonsmatt
Copy link
Collaborator Author

@erikd y'all wanna take a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants