aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql
diff options
context:
space:
mode:
authorRyan Fitzgerald <rwfitzge@gmail.com>2012-04-24 20:43:10 -0700
committerRyan Fitzgerald <rwfitzge@gmail.com>2012-04-24 20:46:51 -0700
commit0c46dbbc4557acb1e0af1c8ce697305398070922 (patch)
tree2c705020e4c200c198fe7566c03c2be1206bdce7 /activerecord/test/cases/adapters/postgresql
parent0cc32c5fd7f875de61262b430bca23825691899b (diff)
downloadrails-0c46dbbc4557acb1e0af1c8ce697305398070922.tar.gz
rails-0c46dbbc4557acb1e0af1c8ce697305398070922.tar.bz2
rails-0c46dbbc4557acb1e0af1c8ce697305398070922.zip
Always quote hstore keys and values
escape_hstore uses quotation marks around keys and values only if it seems necessary. However, it currently breaks in the presence of some non-ASCII characters. Instead of trying to guess exactly which characters are safe, it seems better to always use quotes.
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r--activerecord/test/cases/adapters/postgresql/hstore_test.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb
index 1644a58d92..05d38ec1f1 100644
--- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
require "cases/helper"
require 'active_record/base'
require 'active_record/connection_adapters/postgresql_adapter'
@@ -134,13 +136,19 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase
assert_cycle('a=>b' => 'bar', '1"foo' => '2')
end
+ def test_quoting_special_characters
+ assert_cycle('ca' => 'cà', 'ac' => 'àc')
+ end
+
private
def assert_cycle hash
+ # test creation
x = Hstore.create!(:tags => hash)
x.reload
assert_equal(hash, x.tags)
- # make sure updates work
+ # test updating
+ x = Hstore.create!(:tags => {})
x.tags = hash
x.save!
x.reload