fork github.com/doug-martin

This commit is contained in:
2025-03-22 23:02:05 +08:00
commit f14642a736
131 changed files with 34555 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package exec
import (
"context"
"database/sql"
"git.fsdpf.net/go/db/v2/internal/sb"
)
type (
//nolint:stylecheck // keep name for backwards compatibility
DbExecutor interface {
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}
QueryFactory interface {
FromSQL(sql string, args ...interface{}) QueryExecutor
FromSQLBuilder(b sb.SQLBuilder) QueryExecutor
}
querySupport struct {
de DbExecutor
}
)
func NewQueryFactory(de DbExecutor) QueryFactory {
return &querySupport{de}
}
func (qs *querySupport) FromSQL(query string, args ...interface{}) QueryExecutor {
return newQueryExecutor(qs.de, nil, query, args...)
}
func (qs *querySupport) FromSQLBuilder(b sb.SQLBuilder) QueryExecutor {
query, args, err := b.ToSQL()
return newQueryExecutor(qs.de, err, query, args...)
}