kderme · GitHub

@kderme

parsonsmatt

@erikd erikd mentioned this pull request

Sep 1, 2020

Closed

@kderme

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.

@kderme

parsonsmatt

@parsonsmatt

parsonsmatt changed the base branch from master to foreign-key-improvements

October 30, 2020 18:51

@parsonsmatt

Merged

5 tasks

Read the original on github.com ↗