Skip to content

refactor!: pre-v1.0 API design — var to func, Tx symmetry, ToSQL, Distinct#25

Merged
kolkov merged 2 commits into
mainfrom
refactor/pre-v1-api-design
Jul 3, 2026
Merged

refactor!: pre-v1.0 API design — var to func, Tx symmetry, ToSQL, Distinct#25
kolkov merged 2 commits into
mainfrom
refactor/pre-v1-api-design

Conversation

@kolkov

@kolkov kolkov commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Pre-v1.0 API cleanup — breaking changes that must happen before API freeze. Allowed on v0.x.

Breaking Changes

  • 32 varfunc: All expression builders (Eq, And, Like, etc.) and error helpers (IsUniqueViolation, etc.) are now proper functions with correct godoc signatures. ErrNotFound stays var (sentinel value).
  • Distinct(bool)Distinct(): No parameter, always enables DISTINCT.
  • QueryParams() deprecated: Use Params() instead.

New Features

  • Tx symmetry: BatchInsert(), BatchUpdate(), Upsert(), NewQuery() now available on transactions
  • ToSQL() on all 6 query types: Upsert, BatchInsert, BatchUpdate now support SQL preview
  • ModelQuery.WithContext(ctx): Per-operation context on Model API
  • Query.Params(): Canonical method for query parameters

Test plan

  • All 1600+ tests pass (33 Distinct call sites updated)
  • golangci-lint run ./... = 0 issues
  • Zero var exports remain (except ErrNotFound)
  • All 6 query types have ToSQL()
  • Tx has full method parity with DB

kolkov added 2 commits July 3, 2026 17:48
…hContext, Params, Distinct

BREAKING CHANGES (allowed on v0.x before API freeze):

- 32 exported var → func: Eq, NotEq, And, Or, In, Like, IsUniqueViolation,
  etc. now proper functions with correct godoc signatures. ErrNotFound
  stays var (sentinel error value).
- Distinct(bool) → Distinct() — no parameter, always enables DISTINCT.
  Tests using Distinct(false) restructured to omit the call.
- Params() is now the primary method, QueryParams() deprecated.

NEW FEATURES:

- Tx: BatchInsert, BatchUpdate, Upsert, NewQuery — full parity with DB.
- ToSQL() on UpsertQuery, BatchInsertQuery, BatchUpdateQuery — all 6
  query types now support SQL preview.
- ModelQuery.WithContext(ctx) — per-operation context on Model API.

7 files changed, 243 insertions, 125 deletions.
@kolkov kolkov merged commit 26fe681 into main Jul 3, 2026
8 checks passed
@kolkov kolkov deleted the refactor/pre-v1-api-design branch July 3, 2026 14:51
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 16.84211% with 79 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
db.go 7.24% 64 Missing ⚠️
internal/core/model_query.go 50.00% 9 Missing ⚠️
internal/core/db.go 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant