add ctx/db to all query types

This commit is contained in:
2026-07-07 22:34:02 +01:00
parent f2ebd5b53f
commit f24f15a4f6
5 changed files with 87 additions and 0 deletions
+17
View File
@@ -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