Skip to content

fix(builder): validate dialect clauses and translate MySQL upserts - #778

Merged
cofin merged 13 commits into
mainfrom
flow/builder-unsupported-clause-errors
Sep 13, 2026
Merged

cofin merged 13 commits into
mainfrom
flow/builder-unsupported-clause-errors

Conversation

@cofin

@cofin cofin commented Sep 13, 2026

Copy link
Copy Markdown
Member

Validates locking and conflict clauses in both build() and to_statement() and normalizes dialect aliases. Unsupported clauses raise SQLBuilderError instead of being silently dropped. MariaDB shared locks use LOCK IN SHARE MODE; unsupported lock modifiers are rejected. Spanner's two SQL modes retain plain FOR UPDATE and native upserts, with PostgreSQL-mode assignment restrictions checked.

MySQL/MariaDB conflicts translate to ON DUPLICATE KEY UPDATE, including excluded-value references and DO NOTHING self-assignment. The rewrite preserves the original builder AST and rejects predicates/constraints it cannot preserve. Documentation explains unique-key and trigger differences; regression coverage and v0.63.0 notes are included.

Validation: make lint passed during review. Regression tests were added or updated, but no local test suite was run in this review. Hosted CI for the latest branch head is still pending.

@codecov-commenter

codecov-commenter commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.26%. Comparing base (8547d5d) to head (0aba425).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
sqlspec/builder/_base.py 92.68% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #778      +/-   ##
==========================================
+ Coverage   76.96%   77.26%   +0.29%     
==========================================
  Files         487      488       +1     
  Lines       71929    72084     +155     
  Branches    10075    10115      +40     
==========================================
+ Hits        55361    55695     +334     
+ Misses      13149    13115      -34     
+ Partials     3419     3274     -145     
Flag Coverage Δ
py3.10 76.49% <93.10%> (+0.05%) ⬆️
py3.11 76.50% <93.10%> (+9.91%) ⬆️
py3.12 76.49% <93.10%> (+0.04%) ⬆️
py3.13 66.68% <93.10%> (+0.08%) ⬆️
py3.14 66.22% <93.02%> (+0.09%) ⬆️
unit 67.01% <93.10%> (+0.08%) ⬆️

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

Files with missing lines Coverage Δ
sqlspec/builder/_locking.py 79.59% <100.00%> (+0.86%) ⬆️
sqlspec/builder/_select.py 64.21% <100.00%> (ø)
sqlspec/core/hashing.py 85.96% <ø> (ø)
sqlspec/data_dictionary/_types.py 92.40% <100.00%> (+0.01%) ⬆️
...qlspec/data_dictionary/dialects/bigquery/config.py 100.00% <ø> (ø)
...pec/data_dictionary/dialects/cockroachdb/config.py 100.00% <ø> (ø)
sqlspec/data_dictionary/dialects/duckdb/config.py 100.00% <ø> (ø)
sqlspec/data_dictionary/dialects/mssql/config.py 65.79% <ø> (ø)
sqlspec/data_dictionary/dialects/mysql/config.py 80.68% <ø> (ø)
sqlspec/data_dictionary/dialects/oracle/config.py 82.35% <ø> (ø)
... and 4 more

... and 21 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 changed the title feat(builder): dialect alias normalization, FOR UPDATE gate, and MySQL upsert transpilation (#779) fix(builder): validate dialect clauses and translate MySQL upserts Sep 13, 2026
@cofin
cofin force-pushed the flow/builder-unsupported-clause-errors branch from 5b9d12d to 6a031a6 Compare September 13, 2026 18:05
cofin added a commit that referenced this pull request Sep 13, 2026
cofin added a commit that referenced this pull request Sep 13, 2026
cofin added a commit that referenced this pull request Sep 13, 2026
@cofin
cofin merged commit f469925 into main Sep 13, 2026
3 checks passed
@cofin
cofin deleted the flow/builder-unsupported-clause-errors branch September 13, 2026 20:09
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