forked from denisenkom/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mssql_go19.go
53 lines (47 loc) · 1.05 KB
/
mssql_go19.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
48
49
50
51
52
53
// +build go1.9
package mssql
import (
"database/sql"
"database/sql/driver"
"fmt"
// "github.com/cockroachdb/apd"
)
var _ driver.NamedValueChecker = &MssqlConn{}
func (c *MssqlConn) CheckNamedValue(nv *driver.NamedValue) error {
switch v := nv.Value.(type) {
case sql.Out:
if c.outs == nil {
c.outs = make(map[string]interface{})
}
c.outs[nv.Name] = v.Dest
// Unwrap the Out value and check the inner value.
lnv := *nv
lnv.Value = v.Dest
err := c.CheckNamedValue(&lnv)
if err != nil {
if err != driver.ErrSkip {
return err
}
lnv.Value, err = driver.DefaultParameterConverter.ConvertValue(lnv.Value)
if err != nil {
return err
}
}
nv.Value = sql.Out{Dest: lnv.Value}
return nil
// case *apd.Decimal:
// return nil
default:
return driver.ErrSkip
}
}
func (s *MssqlStmt) makeParamExtra(val driver.Value) (res Param, err error) {
switch val := val.(type) {
case sql.Out:
res, err = s.makeParam(val.Dest)
res.Flags = fByRevValue
default:
err = fmt.Errorf("mssql: unknown type for %T", val)
}
return
}