Hi!
As in title, I try to fabricate hash into hstore type column.
My hstore column name is "status", there I want to set three flags: "processed", "duplicate", "eol". I'm using sequel (4.14.0) as ORM, fabrication (2.8.1), Ruby 2.1.2 and Postgresql of course ;)
case 1:
status {eol: true, duplicate: false, processed: true}
result: syntax error
case 2:
status {"heol"=>"true", "hduplicate"=>"false", "hprocessed"=>"true"}
result: syntax error
case 3:
status do
{"heol"=>"true", "hduplicate"=>"false", "hprocessed"=>"true"}
end
result:
Sequel::DatabaseError:
PG::DatatypeMismatch: ERROR: column "status" is of type hstore but expression is of type boolean
LINE 1: ...23.0, '2000-01-01', (('heol' = '...
HINT: You will need to rewrite or cast the expression.
case 4:
status do
{status: "heol:true"}
end
result:
Failure/Error: Fabricate(:entry)
Sequel::DatabaseError:
PG::UndefinedColumn: ERROR: column "status" does not exist
LINE 1: ...123.0, '2000-01-01', ("status" =...
HINT: There is a column named "status" in table "entries", but it cannot be referenced from this part of the query.
case 5:
status do
{'status' => "heol:true"}
end
result:
Failure/Error: Fabricate(:entry)
Sequel::DatabaseError:
PG::DatatypeMismatch: ERROR: column "status" is of type hstore but expression is of type boolean
LINE 1: ...123.0, '2000-01-01', ('status' =...
HINT: You will need to rewrite or cast the expression.
case 6:
gave up ;)
result:
this post
With FactoryGirl everything works as expected, and syntax is straightforward:
FactoryGirl.define do
factory :entry do
status {{ flag_processed: true, flag_duplicate: false }}
end
Promise to make good use of the correct syntax =)
Thanks!
Lucas.