...
1 package exec
2
3 import (
4 "context"
5 "database/sql"
6
7 "github.com/doug-martin/goqu/v9/internal/sb"
8 )
9
10 type (
11
12 DbExecutor interface {
13 ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
14 QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
15 }
16 QueryFactory interface {
17 FromSQL(sql string, args ...interface{}) QueryExecutor
18 FromSQLBuilder(b sb.SQLBuilder) QueryExecutor
19 }
20 querySupport struct {
21 de DbExecutor
22 }
23 )
24
25 func NewQueryFactory(de DbExecutor) QueryFactory {
26 return &querySupport{de}
27 }
28
29 func (qs *querySupport) FromSQL(query string, args ...interface{}) QueryExecutor {
30 return newQueryExecutor(qs.de, nil, query, args...)
31 }
32
33 func (qs *querySupport) FromSQLBuilder(b sb.SQLBuilder) QueryExecutor {
34 query, args, err := b.ToSQL()
35 return newQueryExecutor(qs.de, err, query, args...)
36 }
37
View as plain text