add ctx/db to all query types
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package sqimple
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// https://www.sqlite.org/lang_delete.html
|
||||
type DeleteStatement struct {
|
||||
Ctx context.Context
|
||||
DB *sql.DB
|
||||
|
||||
table SelectTable
|
||||
|
||||
where []Where
|
||||
@@ -16,6 +21,18 @@ func (s *DeleteStatement) Args() []any {
|
||||
return s.args
|
||||
}
|
||||
|
||||
func (s *DeleteStatement) Exec() (sql.Result, error) {
|
||||
if s.DB != nil {
|
||||
if s.Ctx != nil {
|
||||
return s.DB.ExecContext(s.Ctx, s.String(), s.Args()...)
|
||||
}
|
||||
|
||||
return s.DB.Exec(s.String(), s.Args()...)
|
||||
}
|
||||
|
||||
return nil, ErrNoDatabase
|
||||
}
|
||||
|
||||
func (s *DeleteStatement) IsValid() bool {
|
||||
if !s.table.IsValid() {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user