Skip to content

fix(intent): report filter translates bare to-one relation names to their FK columns - #6309

Merged
delchev merged 1 commit into
masterfrom
fix/report-filter-relation-column
Jul 20, 2026
Merged

fix(intent): report filter translates bare to-one relation names to their FK columns#6309
delchev merged 1 commit into
masterfrom
fix/report-filter-relation-column

Conversation

@delchev

@delchev delchev commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What

A report filter like Status != 8 - where Status is a to-one RELATION of the source entity, not a field - passed through buildWhere untranslated: field names rewrite to their qualified physical columns, but relation names did not, so the generated query carried a nonexistent column (AND Status != 8) and failed at SQL time.

Bare to-one relation names now rewrite to the FK column (Invoice."INVOICE_STATUS" != 8). Guards keep the dotted-ref pass's join-alias tokens (Customer."CUSTOMER_NAME") and already-qualified columns intact (negative lookbehind/lookahead around the token).

Found by a downstream emission audit: an overdue-invoices report excluding a voided status shipped the raw token into the WHERE with every pipeline step green.

Testing

ReportIntentGeneratorTest.filterTranslatesABareToOneRelationToItsFkColumn - bare relation translated, dotted-ref alias unmangled, no raw token left; full class green.

🤖 Generated with Claude Code

…heir FK columns

A report filter like `Status != 8` (a to-one RELATION of the source, not a
field) passed through buildWhere untranslated - fields rewrote to their
qualified physical columns but relation names did not, so the generated query
carried a nonexistent column and failed at SQL time. Bare to-one relation
names now rewrite to the FK column (Invoice."INVOICE_STATUS"), with guards
so join-alias tokens from the dotted-ref pass (Customer."CUSTOMER_NAME")
and already-quoted columns are left intact.

Found by a suite emission audit: an overdue-invoices report excluding a
VOIDED status generated 'AND Status != 8' verbatim into the WHERE.

Verified: ReportIntentGeneratorTest +1 (bare relation translated, dotted-ref
alias unmangled), full class green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@delchev
delchev merged commit 495cb6b into master Jul 20, 2026
10 checks passed
@delchev
delchev deleted the fix/report-filter-relation-column branch July 20, 2026 11:29
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.

1 participant