Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions base.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"reflect"
"strings"
"time"
"database/sql"
)

type base struct {
Expand Down Expand Up @@ -67,6 +68,8 @@ func (d *base) SetModelValue(driverValue, fieldValue reflect.Value) error {
} else {
panic(fmt.Sprintf("cannot set created value %T", driverValue.Elem().Interface()))
}
} else if fieldType == reflect.TypeOf(sql.NullInt64{}) {
fieldValue.Set(reflect.ValueOf(sql.NullInt64{driverValue.Elem().Int(),true}))
}
}
return nil
Expand Down
3 changes: 2 additions & 1 deletion mysql.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hood

import (
"database/sql"
"fmt"
"reflect"
"time"
Expand Down Expand Up @@ -42,7 +43,7 @@ func (d *mysql) SqlType(f interface{}, size int) string {
return "boolean"
case int, int8, int16, int32, uint, uint8, uint16, uint32:
return "int"
case int64, uint64:
case int64, uint64, sql.NullInt64:
return "bigint"
case float32, float64:
return "double"
Expand Down
3 changes: 2 additions & 1 deletion postgres.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hood

import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
"strings"
Expand Down Expand Up @@ -31,7 +32,7 @@ func (d *postgres) SqlType(f interface{}, size int) string {
return "boolean"
case int, int8, int16, int32, uint, uint8, uint16, uint32:
return "integer"
case int64, uint64:
case int64, uint64, sql.NullInt64:
return "bigint"
case float32, float64:
return "double precision"
Expand Down