Skip to content

An agree check can compare against the record's own to-one - #7677

Open
nedelcho-delchev-tues wants to merge 2 commits into
eclipse-dirigible:masterfrom
nedelcho-delchev-tues:issue-7631-agree-own-to-one
Open

nedelcho-delchev-tues wants to merge 2 commits into
eclipse-dirigible:masterfrom
nedelcho-delchev-tues:issue-7631-agree-own-to-one

Conversation

@nedelcho-delchev-tues

Copy link
Copy Markdown
Contributor

Fixes #7631

agree resolved both of its sides as <relation>.<onProperty>, so it could only ever compare two hops. The rule an opening balance needs is the other shape: the record carries a fiscal year (which belongs to a company) and a company of its own, and what has to agree is Year.Company == Company — one hop on the left, none on the right. There was no way to author it.

A side now falls back to the record's own to-one, resolved from the bare relation name by the same walker, and the authoring stays what it was:

- { kind: agree, relations: [year, company], onProperty: company }

The fallback is taken only when the other side's hop resolved. An onProperty that names nothing on either target keeps reporting exactly that, instead of being silently read as a comparison of the two bare foreign keys.

Both sides must still end on the same entity. The widening makes one new mistake reachable — comparing keys from two nomenclatures, a Company id against a Customer id — which is refused for the reason #7095 refuses it one construct over: the comparison can only ever be false.

A failed path now leaves no hop behind. ResolvePathSupport.Walker registered a step for each prefix it walked even when the path went on to fail at its terminal, so the side that falls back would have emitted a load for a record it never reads. A resolve that fails now rolls its steps back, which is right for every caller.

Covered by IntentParserTest.anAgreeSideMayBeTheRecordsOwnToOne (the shape parses, a mismatched nomenclature is refused, a typo'd onProperty still says it names nothing) and EdmIntentGeneratorTest.anAgreeSideMayBeTheRecordsOwnToOne (the own side renders as entity.Company with no hop, and only the hopped side is loaded). The engine-intent suite is green: 1481 tests.

nedelcho-delchev-tues and others added 2 commits October 5, 2026 11:33
`agree` resolved both of its sides as `<relation>.<onProperty>`, so it could
only ever compare two hops. The rule an opening balance needs is the other
shape: the record carries a fiscal `year` (which belongs to a company) and a
`company` of its own, and what has to agree is `Year.Company == Company` - one
hop on the left, none on the right. It could not be authored at all.

A side whose hop does not resolve now falls back to the record's own to-one,
but only when the OTHER side's hop did resolve: an `onProperty` that names
nothing on either target must keep saying so rather than be read as a
comparison of two bare foreign keys. Both sides must still end on the same
entity - comparing a Company key with a Customer key is refused for the reason
eclipse-dirigible#7095 refuses it one construct over, the two nomenclatures making the
comparison always false.

A path that fails also leaves no hop behind in the walker it shares with the
other side, so the own-to-one side emits no load for a record it never reads.

Fixes eclipse-dirigible#7631

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…own-to-one

# Conflicts:
#	.claude/docs/intent-dsl-features.md

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

intent: a check that a to-one's property agrees with the record's OWN to-one (Year.Company == Company) is not expressible

1 participant