crystal-pg icon indicating copy to clipboard operation
crystal-pg copied to clipboard

nilllable Time type fails declared as Time?

Open fridgerator opened this issue 8 years ago • 0 comments

class created like:

class User
  DB.mapping({
    id: Int32?, 
    name: String?,
    some_date: Time?
  })
end

If a record is inserted into the database with a nil column value for some_date, then trying to call User.from_rs(result_set) fails with an error:

Nil assertion failed (Exception)
0x10158ec62: *CallStack::unwind:Array(Pointer(Void)) at ??
0x10158ec01: *CallStack#initialize:Array(Pointer(Void)) at ??
0x10158ebd8: *CallStack::new:CallStack at ??
0x10157b4d1: *raise<Exception>:NoReturn at ??
0x10157b4b1: *raise<String>:NoReturn at ??
0x1015adb93: *Nil#not_nil!:NoReturn at ??
0x10163b935: *User#initialize<PG::ResultSet>:Time at ??
0x10163b539: *User::new<PG::ResultSet>:User at ??
0x10163b4ad: *User::from_rs<PG::ResultSet>:Array(User) at ??
0x10157b068: __crystal_main at ??
0x101589af8: main at ??

fridgerator avatar Dec 13 '16 01:12 fridgerator