postgres_ext 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +15 -5
  3. data/CHANGELOG.md +3 -0
  4. data/Gemfile +2 -2
  5. data/README.md +4 -0
  6. data/docs/type_casting.md +19 -0
  7. data/lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb +149 -3
  8. data/lib/postgres_ext/active_record/relation/predicate_builder.rb +1 -1
  9. data/lib/postgres_ext/version.rb +1 -1
  10. data/spec/columns/array_spec.rb +3 -4
  11. data/spec/columns/ranges/daterange_spec.rb +37 -0
  12. data/spec/columns/ranges/int4range_spec.rb +38 -0
  13. data/spec/columns/ranges/int8range_spec.rb +38 -0
  14. data/spec/columns/ranges/numrange_spec.rb +37 -0
  15. data/spec/columns/ranges/tsrange_spec.rb +37 -0
  16. data/spec/dummy/app/models/person.rb +1 -1
  17. data/spec/dummy/config/application.rb +1 -1
  18. data/spec/dummy/db/migrate/20120501163758_create_people.rb +1 -0
  19. data/spec/dummy/db/schema.rb +9 -8
  20. data/spec/migrations/array_spec.rb +20 -0
  21. data/spec/migrations/ranges/daterange_spec.rb +27 -0
  22. data/spec/migrations/ranges/int4range_spec.rb +27 -0
  23. data/spec/migrations/ranges/int8range_spec.rb +27 -0
  24. data/spec/migrations/ranges/numrange_spec.rb +27 -0
  25. data/spec/migrations/ranges/tsrange_spec.rb +27 -0
  26. data/spec/migrations/ranges/tstzrange_spec.rb +27 -0
  27. data/spec/models/ranges/daterange_spec.rb +88 -0
  28. data/spec/models/ranges/int4range_spec.rb +85 -0
  29. data/spec/models/ranges/int8range_spec.rb +85 -0
  30. data/spec/models/ranges/numrange_spec.rb +85 -0
  31. data/spec/models/ranges/tsrange_spec.rb +89 -0
  32. data/spec/models/ranges/tstzrange_spec.rb +89 -0
  33. data/spec/queries/sanity_spec.rb +1 -0
  34. data/spec/schema_dumper/array_spec.rb +1 -1
  35. data/spec/schema_dumper/ranges/daterange_spec.rb +18 -0
  36. data/spec/schema_dumper/ranges/int4range_spec.rb +18 -0
  37. data/spec/schema_dumper/ranges/int8range_spec.rb +18 -0
  38. data/spec/schema_dumper/ranges/numrange_spec.rb +18 -0
  39. data/spec/schema_dumper/ranges/tsrange_spec.rb +18 -0
  40. data/spec/schema_dumper/ranges/tstzrange_spec.rb +17 -0
  41. metadata +53 -27
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe 'array schema dump' do
4
4
  let!(:connection) { ActiveRecord::Base.connection }
5
5
  after { connection.drop_table :testings }
6
- it 'correctly generates cidr column statements' do
6
+ it 'correctly generates cidr array column statements' do
7
7
  stream = StringIO.new
8
8
  connection.create_table :testings do |t|
9
9
  t.cidr :network_column, :array => true
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'daterange schema dump' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ after { connection.drop_table :testings }
6
+
7
+ it 'correctly generates daterange column statements' do
8
+ stream = StringIO.new
9
+ connection.create_table :testings do |t|
10
+ t.daterange :range
11
+ end
12
+
13
+ ActiveRecord::SchemaDumper.dump(connection, stream)
14
+ output = stream.string
15
+
16
+ output.should match /t\.daterange "range"/
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'intrange schema dump' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ after { connection.drop_table :testings }
6
+
7
+ it 'correctly generates int4range column statements' do
8
+ stream = StringIO.new
9
+ connection.create_table :testings do |t|
10
+ t.int4range :range
11
+ end
12
+
13
+ ActiveRecord::SchemaDumper.dump(connection, stream)
14
+ output = stream.string
15
+
16
+ output.should match /t\.int4range "range"/
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'int8range schema dump' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ after { connection.drop_table :testings }
6
+
7
+ it 'correctly generates int8range column statements' do
8
+ stream = StringIO.new
9
+ connection.create_table :testings do |t|
10
+ t.int8range :range
11
+ end
12
+
13
+ ActiveRecord::SchemaDumper.dump(connection, stream)
14
+ output = stream.string
15
+
16
+ output.should match /t\.int8range "range"/
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'numrange schema dump' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ after { connection.drop_table :testings }
6
+
7
+ it 'correctly generates numrange column statements' do
8
+ stream = StringIO.new
9
+ connection.create_table :testings do |t|
10
+ t.numrange :range
11
+ end
12
+
13
+ ActiveRecord::SchemaDumper.dump(connection, stream)
14
+ output = stream.string
15
+
16
+ output.should match /t\.numrange "range"/
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'tsrange schema dump' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ after { connection.drop_table :testings }
6
+
7
+ it 'correctly generates tsrange column statements' do
8
+ stream = StringIO.new
9
+ connection.create_table :testings do |t|
10
+ t.tsrange :range
11
+ end
12
+
13
+ ActiveRecord::SchemaDumper.dump(connection, stream)
14
+ output = stream.string
15
+
16
+ output.should match /t\.tsrange "range"/
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'tstzrange schema dump' do
4
+ let!(:connection) { ActiveRecord::Base.connection }
5
+ after { connection.drop_table :testings }
6
+ it 'correctly generates tstzrange column statements' do
7
+ stream = StringIO.new
8
+ connection.create_table :testings do |t|
9
+ t.tstzrange :range
10
+ end
11
+
12
+ ActiveRecord::SchemaDumper.dump(connection, stream)
13
+ output = stream.string
14
+
15
+ output.should match /t\.tstzrange "range"/
16
+ end
17
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dan McClain
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-03 00:00:00.000000000 Z
11
+ date: 2013-06-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: pg_array_parser
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec-rails
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bourne
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: pg
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -151,6 +138,11 @@ files:
151
138
  - spec/arel/inet_spec.rb
152
139
  - spec/columns/array_spec.rb
153
140
  - spec/columns/inet_spec.rb
141
+ - spec/columns/ranges/daterange_spec.rb
142
+ - spec/columns/ranges/int4range_spec.rb
143
+ - spec/columns/ranges/int8range_spec.rb
144
+ - spec/columns/ranges/numrange_spec.rb
145
+ - spec/columns/ranges/tsrange_spec.rb
154
146
  - spec/dummy/.gitignore
155
147
  - spec/dummy/README.rdoc
156
148
  - spec/dummy/Rakefile
@@ -210,10 +202,22 @@ files:
210
202
  - spec/migrations/index_spec.rb
211
203
  - spec/migrations/inet_spec.rb
212
204
  - spec/migrations/macaddr_spec.rb
205
+ - spec/migrations/ranges/daterange_spec.rb
206
+ - spec/migrations/ranges/int4range_spec.rb
207
+ - spec/migrations/ranges/int8range_spec.rb
208
+ - spec/migrations/ranges/numrange_spec.rb
209
+ - spec/migrations/ranges/tsrange_spec.rb
210
+ - spec/migrations/ranges/tstzrange_spec.rb
213
211
  - spec/migrations/uuid_spec.rb
214
212
  - spec/models/array_spec.rb
215
213
  - spec/models/ean13_spec.rb
216
214
  - spec/models/inet_spec.rb
215
+ - spec/models/ranges/daterange_spec.rb
216
+ - spec/models/ranges/int4range_spec.rb
217
+ - spec/models/ranges/int8range_spec.rb
218
+ - spec/models/ranges/numrange_spec.rb
219
+ - spec/models/ranges/tsrange_spec.rb
220
+ - spec/models/ranges/tstzrange_spec.rb
217
221
  - spec/queries/array_queries_spec.rb
218
222
  - spec/queries/contains_querie_spec.rb
219
223
  - spec/queries/sanity_spec.rb
@@ -225,37 +229,36 @@ files:
225
229
  - spec/schema_dumper/index_spec.rb
226
230
  - spec/schema_dumper/inet_spec.rb
227
231
  - spec/schema_dumper/macaddr_spec.rb
232
+ - spec/schema_dumper/ranges/daterange_spec.rb
233
+ - spec/schema_dumper/ranges/int4range_spec.rb
234
+ - spec/schema_dumper/ranges/int8range_spec.rb
235
+ - spec/schema_dumper/ranges/numrange_spec.rb
236
+ - spec/schema_dumper/ranges/tsrange_spec.rb
237
+ - spec/schema_dumper/ranges/tstzrange_spec.rb
228
238
  - spec/schema_dumper/uuid_spec.rb
229
239
  - spec/spec_helper.rb
230
240
  homepage: ''
231
241
  licenses: []
242
+ metadata: {}
232
243
  post_install_message:
233
244
  rdoc_options: []
234
245
  require_paths:
235
246
  - lib
236
247
  required_ruby_version: !ruby/object:Gem::Requirement
237
- none: false
238
248
  requirements:
239
- - - ! '>='
249
+ - - '>='
240
250
  - !ruby/object:Gem::Version
241
251
  version: '0'
242
- segments:
243
- - 0
244
- hash: 3683941487581046941
245
252
  required_rubygems_version: !ruby/object:Gem::Requirement
246
- none: false
247
253
  requirements:
248
- - - ! '>='
254
+ - - '>='
249
255
  - !ruby/object:Gem::Version
250
256
  version: '0'
251
- segments:
252
- - 0
253
- hash: 3683941487581046941
254
257
  requirements: []
255
258
  rubyforge_project:
256
- rubygems_version: 1.8.23
259
+ rubygems_version: 2.0.2
257
260
  signing_key:
258
- specification_version: 3
261
+ specification_version: 4
259
262
  summary: Extends ActiveRecord to handle native PostgreSQL data types
260
263
  test_files:
261
264
  - spec/arel/arel_spec.rb
@@ -263,6 +266,11 @@ test_files:
263
266
  - spec/arel/inet_spec.rb
264
267
  - spec/columns/array_spec.rb
265
268
  - spec/columns/inet_spec.rb
269
+ - spec/columns/ranges/daterange_spec.rb
270
+ - spec/columns/ranges/int4range_spec.rb
271
+ - spec/columns/ranges/int8range_spec.rb
272
+ - spec/columns/ranges/numrange_spec.rb
273
+ - spec/columns/ranges/tsrange_spec.rb
266
274
  - spec/dummy/.gitignore
267
275
  - spec/dummy/README.rdoc
268
276
  - spec/dummy/Rakefile
@@ -322,10 +330,22 @@ test_files:
322
330
  - spec/migrations/index_spec.rb
323
331
  - spec/migrations/inet_spec.rb
324
332
  - spec/migrations/macaddr_spec.rb
333
+ - spec/migrations/ranges/daterange_spec.rb
334
+ - spec/migrations/ranges/int4range_spec.rb
335
+ - spec/migrations/ranges/int8range_spec.rb
336
+ - spec/migrations/ranges/numrange_spec.rb
337
+ - spec/migrations/ranges/tsrange_spec.rb
338
+ - spec/migrations/ranges/tstzrange_spec.rb
325
339
  - spec/migrations/uuid_spec.rb
326
340
  - spec/models/array_spec.rb
327
341
  - spec/models/ean13_spec.rb
328
342
  - spec/models/inet_spec.rb
343
+ - spec/models/ranges/daterange_spec.rb
344
+ - spec/models/ranges/int4range_spec.rb
345
+ - spec/models/ranges/int8range_spec.rb
346
+ - spec/models/ranges/numrange_spec.rb
347
+ - spec/models/ranges/tsrange_spec.rb
348
+ - spec/models/ranges/tstzrange_spec.rb
329
349
  - spec/queries/array_queries_spec.rb
330
350
  - spec/queries/contains_querie_spec.rb
331
351
  - spec/queries/sanity_spec.rb
@@ -337,5 +357,11 @@ test_files:
337
357
  - spec/schema_dumper/index_spec.rb
338
358
  - spec/schema_dumper/inet_spec.rb
339
359
  - spec/schema_dumper/macaddr_spec.rb
360
+ - spec/schema_dumper/ranges/daterange_spec.rb
361
+ - spec/schema_dumper/ranges/int4range_spec.rb
362
+ - spec/schema_dumper/ranges/int8range_spec.rb
363
+ - spec/schema_dumper/ranges/numrange_spec.rb
364
+ - spec/schema_dumper/ranges/tsrange_spec.rb
365
+ - spec/schema_dumper/ranges/tstzrange_spec.rb
340
366
  - spec/schema_dumper/uuid_spec.rb
341
367
  - spec/spec_helper.rb