Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate-database: Accept interface in PrepareStmts #1725

Merged
merged 2 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/generate-database/file/boilerplate/boilerplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type dbtx interface {
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

type preparer interface {
Prepare(query string) (*sql.Stmt, error)
}

// RegisterStmt register a SQL statement.
//
// Registered statements will be prepared upfront and re-used, to speed up
Expand All @@ -28,7 +32,7 @@ func RegisterStmt(sqlStmt string) int {

// PrepareStmts prepares all registered statements and returns an index from
// statement code to prepared statement object.
func PrepareStmts(db *sql.DB, skipErrors bool) (map[int]*sql.Stmt, error) {
func PrepareStmts(db preparer, skipErrors bool) (map[int]*sql.Stmt, error) {
index := map[int]*sql.Stmt{}

for code, sqlStmt := range stmts {
Expand Down
6 changes: 5 additions & 1 deletion internal/server/db/cluster/mapper_boilerplate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading