Only mssql needs the conversion

This commit is contained in:
Lunny Xiao 2021-07-28 22:02:16 +08:00
parent 6f1318a388
commit 3aac5860cb
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 8 additions and 1 deletions

View File

@ -974,7 +974,14 @@ func (statement *Statement) convertSQLOrArgs(sqlOrArgs ...interface{}) (string,
return "", nil, err return "", nil, err
} }
if r != nil { if r != nil {
newArgs = append(newArgs, string(r)) // for nvarchar column on mssql, bytes have to be converted as ucs-2 external of driver
// for binary column, a string will be converted as bytes directly. So we have to
// convert bytes as string
if statement.dialect.URI().DBType == schemas.MSSQL {
newArgs = append(newArgs, string(r))
} else {
newArgs = append(newArgs, r)
}
} else { } else {
newArgs = append(newArgs, nil) newArgs = append(newArgs, nil)
} }