postgresql - rails postgres date_time not working properly -
i getting weird error when trying save record datetime postgres. works, see first example. other times doesn't work.
update "client_comments" set "comment" = $1, "conversation_time" = $2, "updated_at" = $3 "client_comments"."id" = 2 [["comment", "test2"], ["conversation_time", "2015-03-09 23:42:00.000000"], ["updated_at", "2015-03-16 23:50:32.307101"]]
works, no problems!
when use form
<%= f.datetime_select :conversation_time, { :start_year => 2010, :end_year => date.today.year } %>
i click update, params are:
parameters: {"utf8"=>"✓", "authenticity_token"=>"iz/ms9mi3k7h0dg05afjaiktudlpug3ipatapgbheqa=", "client_comment"=>{"client_id"=>"1221", "user_id"=>"1", "company_id"=>"mon", "conversation_time(1i)"=>"2015", "conversation_time(2i)"=>"3", "conversation_time(3i)"=>"7", "conversation_time(4i)"=>"19", "conversation_time(5i)"=>"42", "comment"=>"test2"}, "commit"=>"update client comment", "id"=>"2"}
sql is:
update "client_comments" set "conversation_time" = $1, "updated_at" = $2 "client_comments"."id" = 2 [["conversation_time", "2015-03-08 00:42:00.000000"], ["updated_at", "2015-03-17 00:01:43.611166"]]
which causes exception:
pg::datatypemismatch: error: column "conversation_time" of type timestamp without time zone expression of type time without time zone @ character 52 hint: need rewrite or cast expression.
another weird thing hour in case 19 trying set hour 00 in sql, dont know either.
here schema:
# \d+ client_comments table "public.client_comments" column | type | modifiers | storage | stats target | description -------------------+-----------------------------+------------------------------ --------------------------------+----------+--------------+------------- id | integer | not null default nextval('client_comments_id_seq'::regclass) | plain | | client_id | integer | | plain | | user_id | integer | | plain | | company_id | integer | | plain | | comment | text | | extended | | employee_user_id | integer | | plain | | created_at | timestamp without time zone | | plain | | updated_at | timestamp without time zone | | plain | | conversation_time | timestamp without time zone | | plain | | indexes: "client_comments_pkey" primary key, btree (id) "index_client_comments_on_client_id" btree (client_id) "index_client_comments_on_company_id" btree (company_id) "index_client_comments_on_user_id" btree (user_id) has oids: no
rails v 4.1.8 psql (9.3.2)
well not perfect answer, turns out bug either rails 4.1 , pg 0.17.1 or them working together. upgraded rails 4.2.1 (just came out) , pg 0.18.1 , well. note pg 0.81.1 , earlier versions of rails had bug blob support, 4.2.1 seems have fixed that.
Comments
Post a Comment