ar_pg_array 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ar_pg_array/schema.rb +2 -1
- data/spec/fixtures/bulks.yml +8 -1
- data/spec/pg_array_spec.rb +6 -0
- metadata +36 -56
- data/.gitignore +0 -4
data/lib/ar_pg_array/schema.rb
CHANGED
@@ -100,6 +100,7 @@ module ActiveRecord
|
|
100
100
|
|
101
101
|
SARRAY_QUOTED = /^"(.*[^\\])?"$/m
|
102
102
|
SARRAY_PARTIAL = /^".*(\\"|[^"])$/m
|
103
|
+
ESCAPE_ARRAY = Hash.new{|h,k| h[k] = eval("\"#{k}\"") }
|
103
104
|
def self.string_to_text_array(value)
|
104
105
|
return value unless value.is_a? String
|
105
106
|
return nil if value.empty?
|
@@ -113,7 +114,7 @@ module ActiveRecord
|
|
113
114
|
partial = true
|
114
115
|
end
|
115
116
|
if s =~ SARRAY_QUOTED
|
116
|
-
s =
|
117
|
+
s = $1.gsub(/\\([a-z"\\]|\d{3})/){|s| ESCAPE_ARRAY[s]}
|
117
118
|
partial = false
|
118
119
|
elsif s == 'NULL'
|
119
120
|
s = nil
|
data/spec/fixtures/bulks.yml
CHANGED
@@ -19,10 +19,17 @@ third:
|
|
19
19
|
times: [2010-03-01, 2010-04-01]
|
20
20
|
floats: [2.0, 2.5]
|
21
21
|
decimals: [2.0, 2.5]
|
22
|
-
|
22
|
+
fourth:
|
23
23
|
id: 4
|
24
24
|
ints: [ ]
|
25
25
|
strings: [ ]
|
26
26
|
times: [ ]
|
27
27
|
floats: [ ]
|
28
28
|
decimals: [ ]
|
29
|
+
fifth:
|
30
|
+
id: 5
|
31
|
+
ints: [ 10 ]
|
32
|
+
strings: [ "#{1+1}", "\\#{1+1}\"'\\z", "\t\n" ]
|
33
|
+
times: [ ]
|
34
|
+
floats: [ ]
|
35
|
+
decimals: [ ]
|
data/spec/pg_array_spec.rb
CHANGED
@@ -97,6 +97,12 @@ describe "PgArray" do
|
|
97
97
|
map_times(bulk.times).should == map_times(parse_times(%w{2010-04-01 2010-03-01}))
|
98
98
|
end
|
99
99
|
|
100
|
+
it "should be safe for eval" do
|
101
|
+
bulk = Bulk.find(5)
|
102
|
+
bulk.strings.should == ['#{1+1}', '\\#{1+1}"\'\\z', "\t\n"]
|
103
|
+
#$stderr.puts ActiveRecord::ConnectionAdapters::PostgreSQLColumn::ESCAPE_ARRAY.inspect
|
104
|
+
end
|
105
|
+
|
100
106
|
it "should allow to use sql" do
|
101
107
|
bulks_where(['ints && ?', [1,2].pg]).should == bulks_where(:id=>[1,2,3])
|
102
108
|
end
|
metadata
CHANGED
@@ -1,47 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_pg_array
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.7
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
- 6
|
10
|
-
version: 0.9.6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Sokolov Yura aka funny_falcon
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2010-09-10 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: activerecord
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &79833080 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *79833080
|
25
|
+
description: ar_pg_array includes support of PostgreSQL's int[], float[], text[],
|
26
|
+
timestamptz[] etc. into ActiveRecord. You could define migrations for array columns,
|
27
|
+
query on array columns.
|
36
28
|
email: funny.falcon@gmail.com
|
37
29
|
executables: []
|
38
|
-
|
39
30
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
31
|
+
extra_rdoc_files:
|
42
32
|
- README
|
43
|
-
files:
|
44
|
-
- .gitignore
|
33
|
+
files:
|
45
34
|
- MIT-LICENSE
|
46
35
|
- README
|
47
36
|
- Rakefile
|
@@ -63,44 +52,35 @@ files:
|
|
63
52
|
- spec/pg_array_spec.rb
|
64
53
|
- spec/spec.opts
|
65
54
|
- spec/spec_helper.rb
|
66
|
-
has_rdoc: true
|
67
55
|
homepage: http://github.com/funny-falcon/activerecord-postgresql-arrays
|
68
56
|
licenses: []
|
69
|
-
|
70
57
|
post_install_message:
|
71
|
-
rdoc_options:
|
58
|
+
rdoc_options:
|
72
59
|
- --charset=UTF-8
|
73
|
-
require_paths:
|
60
|
+
require_paths:
|
74
61
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
63
|
none: false
|
77
|
-
requirements:
|
78
|
-
- -
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
|
82
|
-
- 0
|
83
|
-
version: "0"
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
69
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
93
74
|
requirements: []
|
94
|
-
|
95
75
|
rubyforge_project: ar-pg-array
|
96
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.8.10
|
97
77
|
signing_key:
|
98
78
|
specification_version: 3
|
99
79
|
summary: Use power of PostgreSQL Arrays in ActiveRecord
|
100
|
-
test_files:
|
80
|
+
test_files:
|
101
81
|
- spec/fixtures/schema.rb
|
102
|
-
- spec/fixtures/tag.rb
|
103
|
-
- spec/fixtures/bulk.rb
|
104
82
|
- spec/fixtures/item.rb
|
105
|
-
- spec/
|
83
|
+
- spec/fixtures/bulk.rb
|
84
|
+
- spec/fixtures/tag.rb
|
106
85
|
- spec/pg_array_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
data/.gitignore
DELETED