quote_ident loses encoding

Issue #163 resolved
Matt Daw created an issue

Calling quote_ident on a UTF8 encoded string "shot_sg_assigned_todělá_kdoconnections" produces ASCII encoded string "\"shot_sg_assigned_tod\xC4\x9Bl\xC3\xA1_kdoconnections\"".

I'm modifying the result using force_encoding, which is a reasonable workaround... but it would be nice to have it fixed in the gem.

Comments (7)

  1. Michael Granger repo owner

    Thanks for reporting this. This should be a pretty small fix, so we'll likely wrap it up into the next release.

  2. Lars Kanis

    I can add this it.

    Connection#quote_ident is the home-brewed version of #escape_identifier which was introduced in postgresql-9.0. So this is duplicated code. Both are almost equally fast in a simple test I just did (quote_ident has a little less overhead for each call but escape_identifier is faster with more than approximately 7 characters) and they do exactly the same. Both don't set the encoding so far. Any thoughts about the future of them? Should we deprecate quote_ident or alias it to escape_identifier or leave it like it is and add a comment only?

  3. Log in to comment