Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Something is wrong with quotes in unicode values #63

Closed
incubus opened this issue Jan 2, 2013 · 1 comment
Closed

Something is wrong with quotes in unicode values #63

incubus opened this issue Jan 2, 2013 · 1 comment

Comments

@incubus
Copy link

incubus commented Jan 2, 2013

Hi! Happy New Year!

I just want to migrate from serialization to hstore and get the strange error:

irb(main):012:0> t = Translation.find(50)

The old serialization:

irb(main):013:0> t.languages
=> {:ru=>"Скидка купоны/подарочные билеты путешествия", :en=>"Travel discount coupons/gift tickets", :zh=>"旅游折扣券/赠票", :fr=>"Voyage rabais coupons cadeaux billets", :de=>"Rabatt-Gutscheine/Gift Fahrkarten"}

The new hstore:

irb(main):014:0> t.lang = { 'zh' => t.languages[:zh] }
=> {"zh"=>"旅游折扣券/赠票"}
irb(main):015:0> t.save

(0.3ms) UPDATE "translations" SET "lang" = 'zh=>旅游折扣券/赠票', "updated_at" = '2013-01-02 00:46:35.002511' WHERE "translations"."id" = 50
ERROR: Syntax error near '?' at position 7
LINE 1: UPDATE "translations" SET "lang" = 'zh=>旅游折扣券/赠票', "u...

ArgumentError: invalid byte sequence in UTF-8
from /Users/incubus/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1141:in ===' from /Users/incubus/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1141:intranslate_exception'

I don't see quotes in SET "lang" = 'zh=>旅游折扣券/赠票' and it also breaks postgresql adapter error output.

It works fine with ASCII:

irb(main):016:0> t.lang = { 'en' => t.languages[:en] }
=> {"en"=>"Travel discount coupons/gift tickets"}
irb(main):017:0> t.save
(0.2ms) UPDATE "translations" SET "lang" = 'en=>"Travel discount coupons/gift tickets"', "updated_at" = '2013-01-02 00:48:39.191811' WHERE "translations"."id" = 50
=> true

@incubus
Copy link
Author

incubus commented Jan 2, 2013

Nevermind, this issue is described there #18 .

@diogob diogob closed this as completed Jan 23, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants