-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstatement.go
47 lines (37 loc) · 1.3 KB
/
statement.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package fireboltgosdk
import (
"context"
"database/sql/driver"
)
type fireboltStmt struct {
execer driver.ExecerContext
queryer driver.QueryerContext
query string
}
// Close the statement makes it unusable anymore
func (stmt *fireboltStmt) Close() error {
stmt.execer = nil
stmt.queryer = nil
stmt.query = ""
return nil
}
// NumInput returns -1, parametrized queries are not implemented
func (stmt *fireboltStmt) NumInput() int {
return -1
}
// Exec calls ExecContext with dummy context
func (stmt *fireboltStmt) Exec(args []driver.Value) (driver.Result, error) {
return stmt.ExecContext(context.TODO(), valueToNamedValue(args))
}
// Query calls QueryContext with dummy context
func (stmt *fireboltStmt) Query(args []driver.Value) (driver.Rows, error) {
return stmt.QueryContext(context.TODO(), valueToNamedValue(args))
}
// QueryContext sends the query to the engine and returns fireboltRows
func (stmt *fireboltStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
return stmt.queryer.QueryContext(ctx, stmt.query, args)
}
// ExecContext sends the query to the engine and returns empty fireboltResult
func (stmt *fireboltStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
return stmt.execer.ExecContext(ctx, stmt.query, args)
}