activerecord2-hstore 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,5 @@
1
+ 1.0.1
2
+ * Corrected Hash.to_hstore to take into account apostrophes (Thanks, sisk)
3
+
4
+ 1.0.0
5
+ * First release
data/README.markdown CHANGED
@@ -28,6 +28,9 @@ Ether by creating a migration in your project that runs this SQL statement
28
28
  or manually running it directly in psql console...
29
29
 
30
30
  CREATE EXTENSION IF NOT EXISTS hstore;
31
+
32
+ **NOTE THAT THE ABOVE SQL WILL ONLY WORK ON POSTGRESQL 9.1 and above. For
33
+ earlier versions, please consult the documentation for enabling hstore**
31
34
 
32
35
  Instead of me trying to hack ActiveRecord to add an actual hstore column type,
33
36
  and risk breaking the universe, just manually write a migration that adds a
@@ -8,7 +8,7 @@ class Hash
8
8
 
9
9
  map { |key, value|
10
10
  pair = [key, value].map { |element|
11
- item = element.to_s.gsub(/"/, '\"')
11
+ item = element.to_s.gsub(/"/, '\"').gsub(/'/, "\'")
12
12
  if element.nil?
13
13
  'NULL'
14
14
  elsif item =~ /[,\s=>]/ || item.blank?
@@ -1,5 +1,5 @@
1
1
  module Activerecord2
2
2
  module Hstore
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
data/spec/hash_spec.rb CHANGED
@@ -12,6 +12,12 @@ describe Hash do
12
12
  {"a b"=>"b"}.to_hstore.should == "\"a b\"=>b"
13
13
  {"a b"=>"b c"}.to_hstore.should == "\"a b\"=>\"b c\""
14
14
  {"a"=>"b c"}.to_hstore.should == "a=>\"b c\""
15
+ {"a"=>"'c"}.to_hstore.should == "a=>'c"
16
+ {"a'f"=>"b'c"}.to_hstore.should == "a'f=>b'c"
17
+ {"a"=>"b' c"}.to_hstore.should == "a=>\"b' c\""
18
+ {"a"=>"b 'c"}.to_hstore.should == "a=>\"b 'c\""
19
+ {"a"=>"b'"}.to_hstore.should == "a=>b'"
20
+ {"a"=>"'b"}.to_hstore.should == "a=>'b"
15
21
  end
16
22
 
17
23
  it "converts a multiball hash to a hstore string" do
@@ -22,6 +28,8 @@ describe Hash do
22
28
  all_should_match({"a"=>"b", "c 1"=>"d"}, [/a=>b/, /\"c 1\"=>d/])
23
29
  all_should_match({:a=>:b, "c 1"=>:"d 1"}, [/a=>b/, /\"c 1\"=>\"d 1\"/])
24
30
  all_should_match({"a"=>"b", :c=>:d, "e 1"=>"f 1"}, [/a=>b/, /c=>d/, /\"e 1\"=>\"f 1\"/])
31
+ all_should_match({"a 1"=>"b'1", "c"=>"d"}, [/\"a 1\"=>b'1/, /c=>d/])
32
+ all_should_match({"a 1"=>"b' 1", "c"=>"d"}, [/\"a 1\"=>\"b' 1\"/, /c=>d/])
25
33
  end
26
34
 
27
35
  def all_should_match(hash, expects)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord2-hstore
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Drake
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-16 00:00:00 Z
18
+ date: 2012-03-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -91,6 +91,7 @@ extra_rdoc_files: []
91
91
  files:
92
92
  - .gitignore
93
93
  - .rspec
94
+ - CHANGELOG
94
95
  - Gemfile
95
96
  - README.markdown
96
97
  - Rakefile