Repository navigation
Conversation
An or's gather cte was joined to the cte before it even when that cte belonged to something else: the patterns before an enclosing or, or the previous query. The first selected those columns twice, so a where like a AND (b OR ((c OR d) AND e)) failed with an ambiguous column. The second built the or from another query's rows, so it returned nothing when that query was empty. Treat an or at group-idx 0 as cte-for-pattern treats a single pattern there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRKkuGrp63pNCgPK1hVdC7
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Fixes #2947.
accumulate-ctesalready avoids joining anor's gather CTE to the previous CTE when that CTE is the last one of a siblingorbranch. It still joins it in two other cases:orstarts a branch of an outeror, where the previous CTE comes from before the outeror;orstarts a pattern group, where the previous CTE belongs to the previous query.The first selects the earlier CTE's columns twice, so Postgres rejects them as ambiguous. The second builds the
orfrom another query's result rows, so it returns nothing when that query is empty.This treats an
orat the start of a group (group-idx0) like a single pattern there.cte-for-patternalready does the same, throughstart-of-group?, and doesn't join to the previous CTE.or-at-the-start-of-a-groupcovers both shapes on the zeneca app. Without the fix, the first assertion fails withambiguous-columnand the second returns no users. I also ran theinstant.db.*,instant.reactive.*andinstant.admin.*suites; all 393 tests passed, with 19,653 assertions.🤖 Generated with Claude Code
https://claude.ai/code/session_01HRKkuGrp63pNCgPK1hVdC7