Skip to content

fix: register CTE schema correctly when params rename columns#21

Merged
dtsong merged 3 commits intomasterfrom
fix/cte-schema-params
Mar 2, 2026
Merged

fix: register CTE schema correctly when params rename columns#21
dtsong merged 3 commits intomasterfrom
fix/cte-schema-params

Conversation

@dtsong
Copy link
Owner

@dtsong dtsong commented Mar 2, 2026

Summary

  • Fix Cte.schema to reflect renamed column names when params are provided, instead of passing through the original source column names
  • Add param count mismatch validation that raises QueryBuilderError
  • Preserve schema type (case sensitivity) through the renaming

Closes #9

Test plan

  • test_cte_schema: non-parameterized CTE passes through source schema unchanged
  • test_cte_schema: parameterized CTE reflects renamed columns with correct types
  • test_cte_schema: param count mismatch raises QueryBuilderError
  • test_cte_schema: schema type (case sensitivity) is preserved
  • All 17 tests in test_query.py pass

🤖 Generated with Claude Code

dtsong and others added 3 commits March 2, 2026 01:00
When a CTE uses params to rename columns, the schema now reflects the
renamed column names instead of passing through the original names.
This prevents silent failures in downstream column lookups.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a post-construction length check to catch duplicate param names
that would collapse into fewer columns (both case-sensitive and
case-insensitive). Also strengthen tests with value assertions and
duplicate detection cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split the guard clause so params on a schema-less source raises
QueryBuilderError instead of silently discarding them. Also pin the
params=[] passthrough behavior with a test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dtsong dtsong merged commit b5045c4 into master Mar 2, 2026
5 of 6 checks passed
@dtsong dtsong deleted the fix/cte-schema-params branch March 2, 2026 09:15
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.

CTE schema not properly registered

1 participant