Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Always escape keys and value to handle Unicode values #18

wants to merge 3 commits into


None yet
6 participants

HiroProt commented Apr 6, 2012

I came across some cases with Unicode values where I'd get an error that it's not a valid UTF-8 byte sequence, so I patched to_hstore to always escape, regardless of whether we think we need to or not.

Another way of fixing this would be to include the cases I came across in the regex that decided whether to escape or not, but I felt that always escaping is safer.

@diogob diogob was assigned May 22, 2012

heeton commented Jul 13, 2012

@HiroProt Would this prevent storing literals like true / integers etc?

It's been a while since I worked on this, but I believe that all you can store is strings anyway.

raul commented Aug 9, 2012

From the README: "hstore keys and values have to be strings."

I found the same problem, the patch solved it 👍


diogob commented Sep 14, 2012

@HiroProt Could you provide some spec so that I can integrate your pull request?

@diogob I believe it's PostgreSQL complaining about the UTF-8, so a proper spec would probably need to hit a real PostgreSQL installation, unless you wanted to mock it all up. Unfortunately, I don't have time to do that at the moment :(


diogob commented Sep 14, 2012

No problem, I'll try to implement them using some mocks, could you provide the data you used that generated the errors?


tomtaylor commented Oct 7, 2012

When I attempt to store a unicode string in hstore it raises Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT on Line 31 of hash.rb. Presumably this is the same issue, but it's raising before the Postgres interaction, so some Ruby tests/specs would catch it.

@diogob diogob closed this Feb 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment