Skip to content

Embed Interface instead of Type#22

Merged
winebarrel merged 1 commit intomainfrom
embed_if
Jan 19, 2026
Merged

Embed Interface instead of Type#22
winebarrel merged 1 commit intomainfrom
embed_if

Conversation

@winebarrel
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings January 19, 2026 07:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the generic database wrapper types (DB[T], Tx[T], Stmt[T]) to embed interfaces instead of concrete types from the database/sql package. This architectural improvement increases flexibility and follows best practices by programming to interfaces rather than implementations.

Changes:

  • Changed DB[T], Tx[T], and Stmt[T] to embed interfaces (iface.DB, iface.Tx, iface.Stmt) instead of concrete types (*sql.DB, *sql.Tx, *sql.Stmt)
  • Removed compile-time assertions from wrapper structs (they're no longer needed since the structs embed interfaces)
  • Added a comprehensive example in cmd/main.go demonstrating type-safe database operations

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
db.go Changed DB[T] to embed iface.DB interface instead of *sql.DB concrete type
tx.go Changed Tx[T] to embed iface.Tx interface instead of *sql.Tx concrete type
stmt.go Changed Stmt[T] to embed iface.Stmt interface instead of *sql.Stmt concrete type
cmd/main.go Added new example demonstrating type-safe database operations with different database types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@winebarrel winebarrel merged commit 5c97781 into main Jan 19, 2026
8 checks passed
@winebarrel winebarrel deleted the embed_if branch January 19, 2026 07: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.

1 participant