Open
Description
This code path in makeParam is being hit because CheckNamedValue sends the sql.Nullable*
type instances to convertInputParameter
func convertInputParameter(val interface{}) (interface{}, error) {
switch v := val.(type) {
case int, int16, int32, int64, int8:
return val, nil
case byte:
return val, nil
case VarChar:
return val, nil
case NVarCharMax:
return val, nil
case VarCharMax:
return val, nil
case NChar:
return val, nil
case DateTime1:
return val, nil
case DateTimeOffset:
return val, nil
case civil.Date:
return val, nil
case civil.DateTime:
return val, nil
case civil.Time:
return val, nil
// case *apd.Decimal:
// return nil
case float32:
return val, nil
default:
return driver.DefaultParameterConverter.ConvertValue(v)
}
}
The DefaultParameterConverter just returns nil
so we lost the type information. If the value implements driver.Valuer
it should be preserved when it has a nil value so makeParam
can use it.
func (s *Stmt) makeParam(val driver.Value) (res param, err error) {
if val == nil {
res.ti.TypeId = typeNull
res.buffer = nil
res.ti.Size = 0
return
}
...
func makeDecl(ti typeInfo) string {
switch ti.TypeId {
case typeNull:
// maybe we should use something else here
// this is tested in TestNull
return "nvarchar(1)"
makeParam should
Activity