Skip to content
This repository

Timestamps with floats are truncated upon save. #28

Closed
runejuhl opened this Issue August 08, 2012 · 0 comments

2 participants

Rune Juhl Jacobsen Zachary Kessin
Rune Juhl Jacobsen

With pgsql, the "seconds" part of a timestamp is a float, ie. {{2012,8,6},{14,21,34.277014}}. When fetching a record using boss_db and resaving it, the float part of the timestamp is truncated.

28> Post2 = boss_db:find("post-2").   
{post,"post-2",<<"d39848df-894a-419d-808b-36df42ca27e9">>,
      "muser-1",<<"f75e4cf9-0e7e-4ce2-9596-fbe297113d06">>,
      {{2012,8,6},{14,21,34.279783}},
      true}
30> Post2U = Post2:set(active, false).
{post,"post-2",<<"d39848df-894a-419d-808b-36df42ca27e9">>,
      "muser-1",<<"f75e4cf9-0e7e-4ce2-9596-fbe297113d06">>,
      {{2012,8,6},{14,21,34.279783}},
      false}
31> Post2U:save().                    
{ok,{post,"post-2",
          <<"d39848df-894a-419d-808b-36df42ca27e9">>,"muser-1",
          <<"f75e4cf9-0e7e-4ce2-9596-fbe297113d06">>,"category-1",
          {{2012,8,6},{14,21,34.279783}},
          false}}
32> boss_db:find("post-2").              
{post,"post-2",<<"d39848df-894a-419d-808b-36df42ca27e9">>,
      "muser-1",<<"f75e4cf9-0e7e-4ce2-9596-fbe297113d06">>,
      {{2012,8,6},{14,21,34.0}},
      false}
33> boss_db:execute("SELECT * FROM posts WHERE id = 2").
{ok,[{column,<<"id">>,int4,4,-1,0},
     {column,<<"uuid">>,{unknown_oid,2950},16,-1,0},
     {column,<<"muser_id">>,int4,4,-1,0},
     {column,<<"revision_prev">>,{unknown_oid,2950},16,-1,0},
     {column,<<"category_id">>,int4,4,-1,0},
     {column,<<"timestamp">>,timestamp,8,-1,0},
     {column,<<"active">>,bool,1,-1,0}],
    [{<<"2">>,<<"d39848df-894a-419d-808b-36df42ca27e9">>,
      <<"1">>,<<"f75e4cf9-0e7e-4ce2-9596-fbe297113d06">>,<<"1">>,
      <<"2012-08-06 14:21:34">>,<<"f">>}]}
Zachary Kessin zkessin referenced this issue from a commit in zkessin/boss_db January 29, 2014
Zachary Kessin fix #28 fb00de0
Zachary Kessin zkessin closed this January 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.