fix(intent): report filter translates bare to-one relation names to their FK columns - #6309
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A report
filterlikeStatus != 8- whereStatusis a to-one RELATION of the source entity, not a field - passed throughbuildWhereuntranslated: 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