You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
3.7 KiB
128 lines
3.7 KiB
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.13.0
|
|
|
|
package mysqlgen
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
type DBTX interface {
|
|
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
|
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
|
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
|
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
|
}
|
|
|
|
func New(db DBTX) *Queries {
|
|
return &Queries{db: db}
|
|
}
|
|
|
|
func Prepare(ctx context.Context, db DBTX) (*Queries, error) {
|
|
q := Queries{db: db}
|
|
var err error
|
|
if q.deleteTagStmt, err = db.PrepareContext(ctx, deleteTag); err != nil {
|
|
return nil, fmt.Errorf("error preparing query DeleteTag: %w", err)
|
|
}
|
|
if q.findTagStmt, err = db.PrepareContext(ctx, findTag); err != nil {
|
|
return nil, fmt.Errorf("error preparing query FindTag: %w", err)
|
|
}
|
|
if q.listListedTagsStmt, err = db.PrepareContext(ctx, listListedTags); err != nil {
|
|
return nil, fmt.Errorf("error preparing query ListListedTags: %w", err)
|
|
}
|
|
if q.listTagsStmt, err = db.PrepareContext(ctx, listTags); err != nil {
|
|
return nil, fmt.Errorf("error preparing query ListTags: %w", err)
|
|
}
|
|
if q.replaceTagStmt, err = db.PrepareContext(ctx, replaceTag); err != nil {
|
|
return nil, fmt.Errorf("error preparing query ReplaceTag: %w", err)
|
|
}
|
|
return &q, nil
|
|
}
|
|
|
|
func (q *Queries) Close() error {
|
|
var err error
|
|
if q.deleteTagStmt != nil {
|
|
if cerr := q.deleteTagStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing deleteTagStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.findTagStmt != nil {
|
|
if cerr := q.findTagStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing findTagStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.listListedTagsStmt != nil {
|
|
if cerr := q.listListedTagsStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing listListedTagsStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.listTagsStmt != nil {
|
|
if cerr := q.listTagsStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing listTagsStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.replaceTagStmt != nil {
|
|
if cerr := q.replaceTagStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing replaceTagStmt: %w", cerr)
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
|
|
switch {
|
|
case stmt != nil && q.tx != nil:
|
|
return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
|
|
case stmt != nil:
|
|
return stmt.ExecContext(ctx, args...)
|
|
default:
|
|
return q.db.ExecContext(ctx, query, args...)
|
|
}
|
|
}
|
|
|
|
func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
|
|
switch {
|
|
case stmt != nil && q.tx != nil:
|
|
return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
|
|
case stmt != nil:
|
|
return stmt.QueryContext(ctx, args...)
|
|
default:
|
|
return q.db.QueryContext(ctx, query, args...)
|
|
}
|
|
}
|
|
|
|
func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
|
|
switch {
|
|
case stmt != nil && q.tx != nil:
|
|
return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
|
|
case stmt != nil:
|
|
return stmt.QueryRowContext(ctx, args...)
|
|
default:
|
|
return q.db.QueryRowContext(ctx, query, args...)
|
|
}
|
|
}
|
|
|
|
type Queries struct {
|
|
db DBTX
|
|
tx *sql.Tx
|
|
deleteTagStmt *sql.Stmt
|
|
findTagStmt *sql.Stmt
|
|
listListedTagsStmt *sql.Stmt
|
|
listTagsStmt *sql.Stmt
|
|
replaceTagStmt *sql.Stmt
|
|
}
|
|
|
|
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
|
return &Queries{
|
|
db: tx,
|
|
tx: tx,
|
|
deleteTagStmt: q.deleteTagStmt,
|
|
findTagStmt: q.findTagStmt,
|
|
listListedTagsStmt: q.listListedTagsStmt,
|
|
listTagsStmt: q.listTagsStmt,
|
|
replaceTagStmt: q.replaceTagStmt,
|
|
}
|
|
}
|