Build fix.
This commit is contained in:
parent
0d418890ab
commit
3f7efb33eb
3 changed files with 12 additions and 11 deletions
|
|
@ -63,7 +63,7 @@ func (nt *NullTime) Scan(value interface{}) error {
|
|||
nt.Time, nt.Valid = tryParseAsTime(value)
|
||||
|
||||
if !nt.Valid {
|
||||
return fmt.Errorf("can't scan time.Time from %v", value)
|
||||
return fmt.Errorf("can't scan time.Time from %q", value)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -84,6 +84,8 @@ func tryParseAsTime(value interface{}) (time.Time, bool) {
|
|||
timeStr = v
|
||||
case []byte:
|
||||
timeStr = string(v)
|
||||
default:
|
||||
return time.Time{}, false
|
||||
}
|
||||
|
||||
for _, format := range formats {
|
||||
|
|
|
|||
|
|
@ -58,25 +58,24 @@ func TestTryAssign(t *testing.T) {
|
|||
testValue := reflect.ValueOf(&destination).Elem()
|
||||
|
||||
// convertible
|
||||
require.True(t, tryAssign(reflect.ValueOf(convertible), testValue.FieldByName("Convertible")))
|
||||
require.NoError(t, tryAssign(reflect.ValueOf(convertible), testValue.FieldByName("Convertible")))
|
||||
require.Equal(t, int64(16), destination.Convertible)
|
||||
|
||||
// 1/0 to bool
|
||||
require.True(t, tryAssign(reflect.ValueOf(intBool1), testValue.FieldByName("IntBool1")))
|
||||
require.NoError(t, tryAssign(reflect.ValueOf(intBool1), testValue.FieldByName("IntBool1")))
|
||||
require.Equal(t, true, destination.IntBool1)
|
||||
require.True(t, tryAssign(reflect.ValueOf(intBool0), testValue.FieldByName("IntBool0")))
|
||||
require.NoError(t, tryAssign(reflect.ValueOf(intBool0), testValue.FieldByName("IntBool0")))
|
||||
require.Equal(t, false, destination.IntBool0)
|
||||
|
||||
require.False(t, tryAssign(reflect.ValueOf(intBool2), testValue.FieldByName("IntBool2")))
|
||||
require.Equal(t, false, destination.IntBool2)
|
||||
require.EqualError(t, tryAssign(reflect.ValueOf(intBool2), testValue.FieldByName("IntBool2")), "can't assign int32(2) to bool")
|
||||
|
||||
// string to float
|
||||
require.True(t, tryAssign(reflect.ValueOf(floatStr), testValue.FieldByName("FloatStr")))
|
||||
require.NoError(t, tryAssign(reflect.ValueOf(floatStr), testValue.FieldByName("FloatStr")))
|
||||
require.Equal(t, 1.11, destination.FloatStr)
|
||||
require.False(t, tryAssign(reflect.ValueOf(floatErr), testValue.FieldByName("FloatErr")))
|
||||
require.EqualError(t, tryAssign(reflect.ValueOf(floatErr), testValue.FieldByName("FloatErr")), "converting driver.Value type string (\"1.abcd2\") to a float64: invalid syntax")
|
||||
require.Equal(t, 0.00, destination.FloatErr)
|
||||
|
||||
// string to string
|
||||
require.True(t, tryAssign(reflect.ValueOf(str), testValue.FieldByName("Str")))
|
||||
require.NoError(t, tryAssign(reflect.ValueOf(str), testValue.FieldByName("Str")))
|
||||
require.Equal(t, str, destination.Str)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -962,7 +962,7 @@ func TestAllTypesInsert(t *testing.T) {
|
|||
tx, err := db.Begin()
|
||||
require.NoError(t, err)
|
||||
|
||||
stmt := AllTypes.INSERT(AllTypes.AllColumns).
|
||||
stmt := AllTypes.INSERT(AllTypes.AllColumns.Except(AllTypes.TimestampPtr)).
|
||||
MODEL(toInsert)
|
||||
|
||||
//fmt.Println(stmt.DebugSql())
|
||||
|
|
@ -970,7 +970,7 @@ func TestAllTypesInsert(t *testing.T) {
|
|||
testutils.AssertExec(t, stmt, tx, 1)
|
||||
|
||||
var dest model.AllTypes
|
||||
err = AllTypes.SELECT(AllTypes.AllColumns).
|
||||
err = AllTypes.SELECT(AllTypes.AllColumns.Except(AllTypes.TimestampPtr)).
|
||||
WHERE(AllTypes.BigInt.EQ(Int(toInsert.BigInt))).
|
||||
Query(tx, &dest)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue