Commit Graph

47 Commits

Author SHA1 Message Date
7f666e0ece Revert "queryer: NULL-tolerant bound for optional single-family forward relations"
This reverts commit 94477b677d.
2026-06-19 15:34:24 -04:00
98a9719509 Revert "queryer: don't emit a parent type-bound for reified-relationship properties"
This reverts commit c97e5d75b3.
2026-06-19 15:34:23 -04:00
c97e5d75b3 queryer: don't emit a parent type-bound for reified-relationship properties
A SINGLE reified-relationship property (e.g. invoice.counterparty,
person.primary_contact — a property whose type is a relationship
subtype) is hydrated by a correlated subquery that joins the
relationship table and correlates source_id/target_id = parent.id; its
discriminators (the relationship subtype and the target's type CASE)
are constrained INSIDE that subquery.

For such a property the resolved edge is a REVERSE traversal
(forward = false) over a generic relationship FK
(fk_relationship_source_entity, destination = entity). compile_
polymorphic_bounds then took the `!edge.forward` branch with
poly_col = destination_columns[1] = "type" and
table_to_alias = "entity", which resolves to the PARENT's entity alias
— emitting a bound like `entity_1.type = 'counterparty'` into the
parent WHERE. No parent row has that type, so EVERY parent was dropped
(e.g. get_invoice returned null for an existing invoice whose
counterparty edge was absent).

Array reified traversals (contacts, occupancies) never hit this: an
array property has no bound_type_name. Only the single form did, and it
was previously unexercised.

Fix: in compile_polymorphic_bounds, skip the bound when the property's
resolved type is itself a relationship (type_def.relationship) — there
is no parent-row discriminator column to bound.

Test: new queryer case (person.primary_contact, type=contact) asserts
the parent WHERE has no spurious entity.type bound while the subquery
keeps its discriminator + source_id correlation. Full suite green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 11:03:13 -04:00
94477b677d queryer: NULL-tolerant bound for optional single-family forward relations
An OPTIONAL forward polymorphic relation declared via `family` (e.g.
order.counterparty / invoice.counterparty) had its auto-generated type
bound `{alias}.{disc} IN (variations)` emitted into the PARENT row's
WHERE. When the relation is absent (NULL discriminator) the parent row
was wrongly excluded — a counterparty-less order/invoice returned
nothing instead of the row with `counterparty: null`.

Fix: in `compile_polymorphic_bounds`, make the forward-FK bound
NULL-tolerant (`(… IN (…) OR …_type IS NULL)`), gated on
`!r#type.relationship`:
  - real entities get NULL-tolerance (the relation is an optional
    attribute; an absent one must not drop the row — the inner CASE
    already resolves it to NULL);
  - edge entities (`relationship == true`, e.g. `contact`) keep the
    bound EXACT, because there source_type/target_type *partition*
    typed sub-collections (phone_numbers vs email_addresses) and a NULL
    endpoint belongs to no partition.

Note: the `oneOf` path was already correct — it emits no parent bound
(resolves via CASE … ELSE NULL), so cross-family optional relations
already hydrate NULL-safely. Added a fixture case documenting that.

Tests (fixtures/queryer.json): case 15 (entity → NULL-tolerant),
cases 3/5/10 (contact edges → exact, unchanged), new case 16
(oneOf cross-family → no bound). Full suite green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 10:22:29 -04:00
c5d652c6fd fixed merger ordering issue 2026-06-15 16:41:59 -04:00
ea03584bbd re-applied fix for family in conditions 2026-05-28 14:54:57 -04:00
b0fc6c12ef fixed queryer issue with nested families 2026-05-21 13:26:07 -04:00
2a8b991269 fixed ordering of all things sql 2026-05-14 05:58:38 -04:00
3034406706 fixing ordering checkpoint 2026-05-14 03:21:12 -04:00
98e7f5da12 fixed oneOf case queryer issue with resolving the table alias 2026-04-28 15:07:01 -04:00
69bd726b25 more filter fixes 2026-04-17 07:43:19 -04:00
509194b55f in, nin to of, nof for go and dart generator compatibility 2026-04-17 02:24:03 -04:00
41649766db to family 2026-04-16 11:54:37 -04:00
77af67aef5 beefed up schema compiled properties with cases properties and added tests with cases to queryer and merger 2026-04-16 11:00:26 -04:00
a3bd79deef jspg stabilized again 2026-04-15 03:08:11 -04:00
8984acaa5f added jsonb field tests to queryer and merger and fixed a bug there 2026-04-14 13:23:01 -04:00
0017c598e1 chore: JSPG Engine tuple decoupling and core routing optimizations 2026-04-13 22:41:32 -04:00
be78af1507 more tests 2026-04-10 01:06:02 -04:00
3cca5ef2d5 checkpoint 2026-04-09 19:55:35 -04:00
5f45df6c11 checkpoint 2026-04-09 18:39:52 -04:00
7c8df22709 massively improves the jspg validator by removing mathmatical functions like allOf, anyOf, ref, etc to effectively use discriminators and OOP with types to determine valid pathing an nno intersections, unions, or guesswork; added cases to replace the former conditionals 2026-04-08 13:08:24 -04:00
06f6a587de progress 2026-04-02 21:55:57 -04:00
7523431007 test pgrx no fixes 2026-03-27 18:02:24 -04:00
e86fe5cc4e fixed relationship resolution in merger and queryer 2026-03-27 16:35:23 -04:00
f5bf21eb58 fixed root array queries 2026-03-25 21:37:01 -04:00
8dcc714963 fixed target_type restrictions in where clauses 2026-03-23 16:41:34 -04:00
10c57e59ec fixed nested filtering syntax 2026-03-23 14:37:22 -04:00
14707330a7 subschema id queryer test added 2026-03-22 05:54:31 -04:00
847e921b1c stems removed from queryer 2026-03-18 22:04:29 -04:00
00375c2926 more fixes 2026-03-18 04:39:48 -04:00
330280ba48 queryer fixes 2026-03-18 02:41:56 -04:00
091007006d queryer fixes in place 2026-03-17 22:13:34 -04:00
e078b8a74b queryer alias fixes installed 2026-03-17 05:42:27 -04:00
08768e3d42 queryer fixes 2026-03-16 18:05:47 -04:00
5d11c4c92c jspg query with familties fixes 2026-03-16 06:07:13 -04:00
db5183930d queryer supports subfiltering now 2026-03-15 07:49:05 -04:00
6632570712 merger improvements 2026-03-15 03:24:00 -04:00
290464adc1 gjson pathing for stem paths 2026-03-13 23:35:37 -04:00
cfcb259eab final queryer and merger test suite installed; docs fully up to date 2026-03-12 18:37:50 -04:00
f666e608da more tests progress 2026-03-12 18:24:13 -04:00
732034bbc7 more tests progress 2026-03-12 17:46:38 -04:00
5b183a1aba test cleanup 2026-03-11 23:19:51 -04:00
be1367930d test cleanups passing 2026-03-11 21:55:37 -04:00
44ba3e0e18 test cleanup 2026-03-11 21:11:31 -04:00
641f7b5d92 all tests passing again 2026-03-11 18:38:37 -04:00
c007d7d479 test checkpoint 2026-03-11 17:46:08 -04:00
44be75f5d4 queryer merger test progress 2026-03-11 05:18:01 -04:00