Commit d36a1dad authored by gwenn's avatar gwenn

Add test scanning null time.

parent ea526be7
......@@ -43,7 +43,7 @@ type UnixTime time.Time
func (t *UnixTime) Scan(src interface{}) error {
if src == nil {
t = nil
//t = nil
return nil
} else if unixepoch, ok := src.(int64); ok {
*t = UnixTime(time.Unix(unixepoch, 0)) // local time
......@@ -63,7 +63,7 @@ type JulianTime time.Time
func (t *JulianTime) Scan(src interface{}) error {
if src == nil {
t = nil
//t = nil
return nil
} else if jd, ok := src.(float64); ok {
*t = JulianTime(JulianDayToLocalTime(jd)) // local time
......@@ -83,7 +83,7 @@ type TimeStamp time.Time
func (t *TimeStamp) Scan(src interface{}) error {
if src == nil {
t = nil
//t = nil
return nil
} else if txt, ok := src.(string); ok {
v, err := time.Parse("2006-01-02T15:04:05.999Z07:00", txt)
......
......@@ -33,7 +33,7 @@ func TestBindTime(t *testing.T) {
}
}
func TestScan(t *testing.T) {
func TestScanTime(t *testing.T) {
db := open(t)
defer checkClose(db, t)
var dt time.Time
......@@ -72,6 +72,18 @@ func TestScan(t *testing.T) {
}
}
func TestScanNullTime(t *testing.T) {
db := open(t)
defer checkClose(db, t)
var unix UnixTime
err := db.OneValue("SELECT NULL", &unix)
checkNoError(t, err, "Error scanning null time: %#v")
if !(time.Time)(unix).IsZero() {
t.Error("Expected zero time")
}
}
func TestBindTimeAsString(t *testing.T) {
db := open(t)
defer checkClose(db, t)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment