implementation scan for mssql
This commit is contained in:
parent
42c6d33a9a
commit
e1b390a91c
|
@ -14,6 +14,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/core"
|
||||||
|
"xorm.io/xorm/internal/convert"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -712,3 +713,35 @@ func (p *odbcDriver) GenScanResult(colType string) (interface{}, error) {
|
||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *odbcDriver) Scan(ctx *ScanContext, rows *core.Rows, types []*sql.ColumnType, vv ...interface{}) error {
|
||||||
|
var scanResults = make([]interface{}, 0, len(types))
|
||||||
|
var replaces = make([]bool, 0, len(types))
|
||||||
|
var err error
|
||||||
|
for i, v := range vv {
|
||||||
|
var replaced bool
|
||||||
|
var scanResult interface{}
|
||||||
|
if types[i].DatabaseTypeName() == "NVARCHAR" {
|
||||||
|
scanResult = &sql.RawBytes{}
|
||||||
|
replaced = true
|
||||||
|
} else {
|
||||||
|
scanResult = v
|
||||||
|
}
|
||||||
|
|
||||||
|
scanResults = append(scanResults, scanResult)
|
||||||
|
replaces = append(replaces, replaced)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = rows.Scan(scanResults...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, replaced := range replaces {
|
||||||
|
if replaced {
|
||||||
|
if err = convert.Assign(vv[i], scanResults[i], ctx.DBLocation, ctx.UserLocation); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue