Skip to content

fix: replace all public API panics with stored errors, register pgx#24

Merged
kolkov merged 2 commits into
mainfrom
fix/panic-to-error-handling
Jul 3, 2026
Merged

fix: replace all public API panics with stored errors, register pgx#24
kolkov merged 2 commits into
mainfrom
fix/panic-to-error-handling

Conversation

@kolkov

@kolkov kolkov commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Zero panics from public API: all 17 panic paths converted to stored buildErr errors that propagate through Build()/Execute()/All()/One()
  • pgx dialect registered: Open("pgx", dsn) now works as PostgreSQL
  • Model(nil) safe: nil guard returns clean error instead of nil pointer dereference
  • GetDialect actionable: panic message lists all supported dialects and suggests RegisterDialect()

Affected methods

SelectQuery: Where(), OrWhere(), Having(), FromSelect(), With(), WithRecursive(), JOIN ON
UpdateQuery/DeleteQuery: Where(), OrWhere()
BatchInsertQuery: Values(), Build()
BatchUpdateQuery: Build()
LikeExp: EscapeChars()

Test plan

  • 19 new test functions (309 lines) in builder_error_test.go
  • All existing tests updated (panic assertions → error assertions)
  • All 1600+ tests pass
  • golangci-lint run ./... = 0 issues
  • Only 2 panics remain: WrapDB(nil) (constructor) and GetDialect(unknown) (actionable message)

kolkov added 2 commits July 3, 2026 16:14
…ialect

17 panic paths converted to stored buildErr pattern across SelectQuery,
UpdateQuery, DeleteQuery, BatchInsertQuery, BatchUpdateQuery, and LikeExp.
Errors propagate through Build()/Execute()/All()/One() via Query.prepErr.

- SelectQuery: Where/OrWhere/Having wrong type, FromSelect empty alias,
  With/WithRecursive invalid args, JOIN invalid ON type
- UpdateQuery/DeleteQuery: Where/OrWhere wrong type
- BatchInsertQuery: Values() count mismatch, Build() no rows
- BatchUpdateQuery: Build() no updates
- LikeExp: EscapeChars() odd argument count
- Model(nil): nil guard in inferTableName
- WrapDB(nil): clear panic message at construction
- GetDialect: actionable error listing supported dialects
- RegisterDialect pgx as PostgresDialect

19 new test functions (309 lines) in builder_error_test.go.
@kolkov kolkov merged commit 6c54457 into main Jul 3, 2026
8 checks passed
@kolkov kolkov deleted the fix/panic-to-error-handling branch July 3, 2026 13:16
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/core/db.go 0.00% 1 Missing and 1 partial ⚠️
internal/core/model_query.go 0.00% 1 Missing and 1 partial ⚠️

📢 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