Skip to content

feat(builder): consolidate expression construction#639

Merged
cofin merged 12 commits into
mainfrom
agent/codebase-c14-builder
Jul 11, 2026
Merged

feat(builder): consolidate expression construction#639
cofin merged 12 commits into
mainfrom
agent/codebase-c14-builder

Conversation

@cofin

@cofin cofin commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

  • share window, dialect, column, SQL-object, DDL, and statement-detection helpers
  • widen scalar functions to accept builder-native column, wrapper, and case expressions
  • add ordered count_over() support and reconcile SQLGlot required expression arguments
  • preserve parameter merging for both SQL-text and expression-plus-parameters protocol shapes

Why

Builder expression construction had accumulated parallel normalization, coercion, and parsing paths. Consolidating them reduces drift while preserving rendered SQL and parameter binding.

Impact

count_over() now accepts order_by consistently with other window helpers. Scalar and aggregate helpers accept the same builder-native expression shapes. WHERE, subquery, and JOIN inputs now consistently retain placeholders and values across both supported SQL-object protocols. Materialized views render canonical PostgreSQL WITH DATA and WITH NO DATA clauses.

Validation

  • uv run pytest tests/unit/builder/ -q (911 passed)
  • make lint
  • make type-check
  • focused SQL-object protocol, SQLGlot argument-contract, DDL, factory, and select suites

The repository compiled-install target was attempted twice but stalled without diagnostics during the package build; each attempt was interrupted and its temporary build configuration was restored.

@codecov-commenter

codecov-commenter commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.54545% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.95%. Comparing base (6bb5742) to head (407525f).

Files with missing lines Patch % Lines
sqlspec/builder/_factory.py 85.88% 12 Missing ⚠️
sqlspec/builder/_parsing_utils.py 70.96% 5 Missing and 4 partials ⚠️
sqlspec/builder/_select.py 52.63% 6 Missing and 3 partials ⚠️
sqlspec/builder/_ddl.py 82.14% 4 Missing and 1 partial ⚠️
sqlspec/builder/_join.py 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #639      +/-   ##
==========================================
+ Coverage   76.82%   76.95%   +0.13%     
==========================================
  Files         473      473              
  Lines       66108    66076      -32     
  Branches     9821     9799      -22     
==========================================
+ Hits        50785    50850      +65     
+ Misses      12031    11956      -75     
+ Partials     3292     3270      -22     
Flag Coverage Δ
integration 60.06% <28.97%> (+0.02%) ⬆️
py3.10 75.21% <79.54%> (+0.14%) ⬆️
py3.11 75.22% <79.54%> (+0.14%) ⬆️
py3.12 75.23% <79.54%> (+0.14%) ⬆️
py3.13 75.22% <79.54%> (+0.14%) ⬆️
py3.14 76.16% <79.54%> (+0.15%) ⬆️
unit 64.06% <79.54%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sqlspec/builder/_base.py 74.14% <100.00%> (-0.86%) ⬇️
sqlspec/builder/_column.py 76.34% <100.00%> (+1.61%) ⬆️
sqlspec/builder/_merge.py 82.83% <100.00%> (ø)
sqlspec/builder/_join.py 69.07% <80.00%> (+1.75%) ⬆️
sqlspec/builder/_ddl.py 65.53% <82.14%> (+2.70%) ⬆️
sqlspec/builder/_parsing_utils.py 72.82% <70.96%> (+6.15%) ⬆️
sqlspec/builder/_select.py 63.49% <52.63%> (+1.25%) ⬆️
sqlspec/builder/_factory.py 81.83% <85.88%> (+8.16%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cofin cofin marked this pull request as ready for review July 11, 2026 02:57
@cofin cofin merged commit 44a3283 into main Jul 11, 2026
24 checks passed
@cofin cofin deleted the agent/codebase-c14-builder branch July 11, 2026 02:57
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.

2 participants