Skip to content

fix(#532): align window total schema mapping#541

Merged
cofin merged 1 commit into
mainfrom
fix/select-with-total
Jun 26, 2026
Merged

fix(#532): align window total schema mapping#541
cofin merged 1 commit into
mainfrom
fix/select-with-total

Conversation

@cofin

@cofin cofin commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

Closes #532.

  • Route select_with_total(count_with_window=True) window rows through the normal schema conversion path in both sync and async drivers.
  • Keep _add_count_over_column() and _extract_total_from_rows() unchanged; the generated SQL was already correct.
  • Add sync SQLite and async aiosqlite regressions for msgspec.Struct schemas that omit an extra selected column.

Root Cause

The two-query path used SQLResult.get_data(schema_type=...), but the window-count path stripped _total_count and then constructed schema objects directly with schema_type(**row). Direct msgspec.Struct construction rejects unmapped columns, while the normal SQLSpec conversion path tolerates them.

@cofin cofin marked this pull request as ready for review June 26, 2026 00:27
@codecov-commenter

codecov-commenter commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.55%. Comparing base (77aafaa) to head (cb8b761).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #541      +/-   ##
==========================================
+ Coverage   75.54%   75.55%   +0.01%     
==========================================
  Files         444      444              
  Lines       58791    58791              
  Branches     9132     9132              
==========================================
+ Hits        44411    44418       +7     
+ Misses      11506    11500       -6     
+ Partials     2874     2873       -1     
Flag Coverage Δ
integration 59.34% <0.00%> (-0.01%) ⬇️
py3.10 73.93% <100.00%> (+0.01%) ⬆️
py3.11 73.95% <100.00%> (+0.01%) ⬆️
py3.12 73.94% <100.00%> (+0.01%) ⬆️
py3.13 73.94% <100.00%> (+0.01%) ⬆️
py3.14 74.75% <100.00%> (+0.01%) ⬆️
unit 61.42% <100.00%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
sqlspec/driver/_async.py 81.02% <100.00%> (+1.45%) ⬆️
sqlspec/driver/_sync.py 81.06% <100.00%> (+0.48%) ⬆️

... and 1 file 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 merged commit c5e0154 into main Jun 26, 2026
24 checks passed
@cofin cofin deleted the fix/select-with-total branch June 26, 2026 00:49
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.

select_with_total(count_with_window=True) raises TypeError on SELECT columns absent from schema_type

2 participants