Statements execution with context.
This commit is contained in:
parent
cdfd8f1dff
commit
1ac324e198
11 changed files with 146 additions and 28 deletions
|
|
@ -1,9 +1,7 @@
|
|||
package sqlbuilder
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"github.com/go-jet/jet/sqlbuilder/execution"
|
||||
"github.com/serenize/snaker"
|
||||
"reflect"
|
||||
)
|
||||
|
|
@ -185,23 +183,3 @@ func mustBe(v reflect.Value, expected reflect.Kind) {
|
|||
panic("argument mismatch: expected " + expected.String() + ", got " + v.Type().String())
|
||||
}
|
||||
}
|
||||
|
||||
func Query(statement Statement, db execution.Db, destination interface{}) error {
|
||||
query, args, err := statement.Sql()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return execution.Query(db, query, args, destination)
|
||||
}
|
||||
|
||||
func Exec(statement Statement, db execution.Db) (res sql.Result, err error) {
|
||||
query, args, err := statement.Sql()
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return db.Exec(query, args...)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue