activerecord-postgis-adapter 0.7.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f82fbbcef576636f810f2e8377d0b8ccbb18984c
4
- data.tar.gz: 6b5a4d0cb7364ca9a065505a27e8d93781cdcb39
3
+ metadata.gz: 578cf1645006c531d621eec0e5053b6d95565c5a
4
+ data.tar.gz: 961688115ef7f7b687867c2779b6079eecca4048
5
5
  SHA512:
6
- metadata.gz: 0e706c148799b75f93653e4f87eaffc9dce2f57375c1c380e80006056ea672663756e684b19da3e80ab9f1c71e23c99662db7151d4d6a68aaa38eed580910a31
7
- data.tar.gz: 22aed0f63250fae535d9d81e988f0b3dd0929b7a9979bad6e0c1a0fc27f2a2cfe6864d4d23976ccccf9b3d1932e7e44ede08338bc7cf122e5a64a48d3bb11d95
6
+ metadata.gz: b67b0163560b4b28dda0118698b15b423c8f55e55c89f8593d3655eefde8c128a348e75483ed0ef479a15fda1e7af3394eb61ee60c59199e86dc5dd3339d9612
7
+ data.tar.gz: 639952e0e47566dfd8e33a9979c28f002b0fa6b13b6db3b90a73b9b1f9b931e9891cc5ad20c97c3ebcd3fbf5fa5d932848df172149bcdaa0b9a08a8f391a8fb7
data/History.rdoc CHANGED
@@ -1,4 +1,14 @@
1
- === 0.7.0 / 2014-04-04
1
+ === 1.0.0 / 2014-05-06
2
+
3
+ * Require rgeo-activerecord 1.0.0
4
+ * Require ActiveRecord 4.1
5
+
6
+ === 0.7.1 / 2014-05-06
7
+
8
+ * Updates for the Rails 4.0.x-compatible adapater can be found on the 0.7-stable branch
9
+ * Require rgeo-activerecord 0.6.0, which includes bug fixes for Rails 4.0.x
10
+
11
+ === 0.7.0 / 2014-05-06
2
12
 
3
13
  * Version 0.7.0 is for Rails 4.0.x
4
14
  * Require ruby 1.9.3+
@@ -33,7 +33,7 @@ module ActiveRecord # :nodoc:
33
33
  table_name_ = table_name_.to_s
34
34
  spatial_info_ = spatial_column_info(table_name_)
35
35
  column_definitions(table_name_).collect do |col_name_, type_, default_, notnull_, oid_, fmod_|
36
- oid_ = OID::TYPE_MAP.fetch(oid_.to_i, fmod_.to_i) {
36
+ oid_ = type_map.fetch(oid_.to_i, fmod_.to_i) {
37
37
  OID::Identity.new
38
38
  }
39
39
  SpatialColumn.new(@rgeo_factory_settings, table_name_, col_name_, default_, oid_, type_,
@@ -87,9 +87,9 @@ module ActiveRecord # :nodoc:
87
87
  end.compact
88
88
  end
89
89
 
90
- def create_table_definition(name_, temporary_, options_)
90
+ def create_table_definition(name_, temporary_, options_, as_=nil)
91
91
  # Override to create a spatial table definition (post-4.0.0.beta1)
92
- PostGISAdapter::TableDefinition.new(native_database_types, name_, temporary_, options_, self)
92
+ PostGISAdapter::TableDefinition.new(native_database_types, name_, temporary_, options_, as_, self)
93
93
  end
94
94
 
95
95
  def create_table(table_name_, options_={}, &block_)
@@ -112,13 +112,6 @@ module ActiveRecord # :nodoc:
112
112
  end
113
113
  end
114
114
 
115
- def drop_table(table_name_, *options_)
116
- if postgis_lib_version.to_s.split('.').first.to_i == 1
117
- execute("DELETE from geometry_columns where f_table_name='#{quote_string(table_name_.to_s)}'")
118
- end
119
- super
120
- end
121
-
122
115
  def add_column(table_name_, column_name_, type_, options_={})
123
116
  table_name_ = table_name_.to_s
124
117
  column_name_ = column_name_.to_s
@@ -134,7 +127,7 @@ module ActiveRecord # :nodoc:
134
127
  type_ = (options_[:type] || info_[:type] || type_).to_s.gsub('_', '').upcase
135
128
  has_z_ = options_[:has_z]
136
129
  has_m_ = options_[:has_m]
137
- srid_ = (options_[:srid] || -1).to_i
130
+ srid_ = (options_[:srid] || PostGISAdapter::DEFAULT_SRID).to_i
138
131
  if options_[:geographic]
139
132
  type_ << 'Z' if has_z_
140
133
  type_ << 'M' if has_m_
@@ -11,14 +11,13 @@ module ActiveRecord # :nodoc:
11
11
  def initialize(factory_settings_, table_name_, name_, default_, oid_type_, sql_type_=nil, null_=true, opts_=nil)
12
12
  @factory_settings = factory_settings_
13
13
  @table_name = table_name_
14
- @geographic = sql_type_ =~ /geography/i ? true : false
14
+ @geographic = !!(sql_type_ =~ /geography/i)
15
15
  if opts_
16
16
  # This case comes from an entry in the geometry_columns table
17
- @geometric_type = ::RGeo::ActiveRecord.geometric_type_from_name(opts_[:type]) ||
18
- ::RGeo::Feature::Geometry
17
+ @geometric_type = ::RGeo::ActiveRecord.geometric_type_from_name(opts_[:type]) || ::RGeo::Feature::Geometry
19
18
  @srid = opts_[:srid].to_i
20
- @has_z = opts_[:has_z] ? true : false
21
- @has_m = opts_[:has_m] ? true : false
19
+ @has_z = !!opts_[:has_z]
20
+ @has_m = !!opts_[:has_m]
22
21
  elsif @geographic
23
22
  # Geographic type information is embedded in the SQL type
24
23
  @geometric_type = ::RGeo::Feature::Geometry
@@ -7,10 +7,10 @@ module ActiveRecord # :nodoc:
7
7
 
8
8
  class TableDefinition < ConnectionAdapters::PostgreSQLAdapter::TableDefinition # :nodoc:
9
9
 
10
- def initialize(types_, name_, temporary_, options_, base_)
10
+ def initialize(types_, name_, temporary_, options_, as_, base_)
11
11
  @base = base_
12
12
  @spatial_columns_hash = {}
13
- super(types_, name_, temporary_, options_)
13
+ super(types_, name_, temporary_, options_, as_)
14
14
  end
15
15
 
16
16
  def column(name_, type_, options_={})
@@ -80,7 +80,11 @@ module ActiveRecord # :nodoc:
80
80
  end
81
81
 
82
82
  def srid
83
- @srid ? @srid.to_i : (geographic? ? 4326 : -1)
83
+ if @srid
84
+ @srid.to_i
85
+ else
86
+ geographic? ? 4326 : PostGISAdapter::DEFAULT_SRID
87
+ end
84
88
  end
85
89
 
86
90
  def has_z?
@@ -5,6 +5,9 @@ module ActiveRecord # :nodoc:
5
5
  :geography => {:type => 'geometry', :geographic => true}
6
6
  )
7
7
 
8
+ # http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
9
+ DEFAULT_SRID = 0
10
+
8
11
  module CommonAdapterMethods # :nodoc:
9
12
  def set_rgeo_factory_settings(factory_settings_)
10
13
  @rgeo_factory_settings = factory_settings_
@@ -22,9 +25,8 @@ module ActiveRecord # :nodoc:
22
25
  @postgis_lib_version ||= select_value("SELECT PostGIS_Lib_Version()")
23
26
  end
24
27
 
25
- # http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
26
28
  def default_srid
27
- 0
29
+ DEFAULT_SRID
28
30
  end
29
31
 
30
32
  def srs_database_columns
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  module PostGISAdapter
4
- VERSION = "0.7.1".freeze
4
+ VERSION = "1.0.0".freeze
5
5
  end
6
6
  end
7
7
  end
data/test/tc_basic.rb CHANGED
@@ -7,7 +7,7 @@ module RGeo
7
7
  module PostGISAdapter # :nodoc:
8
8
  module Tests # :nodoc:
9
9
 
10
- class TestBasic < ::MiniTest::Unit::TestCase # :nodoc:
10
+ class TestBasic < ::MiniTest::Test # :nodoc:
11
11
 
12
12
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
13
13
  OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database_local.yml'
data/test/tc_ddl.rb CHANGED
@@ -1,21 +1,16 @@
1
1
  require 'minitest/autorun'
2
2
  require 'rgeo/active_record/adapter_test_helper'
3
3
 
4
-
5
4
  module RGeo
6
5
  module ActiveRecord # :nodoc:
7
6
  module PostGISAdapter # :nodoc:
8
7
  module Tests # :nodoc:
9
-
10
- class TestDDL < ::MiniTest::Unit::TestCase # :nodoc:
11
-
8
+ class TestDDL < ::MiniTest::Test # :nodoc:
12
9
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
13
10
  OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database_local.yml'
14
11
  include AdapterTestHelper
15
12
 
16
13
  define_test_methods do
17
-
18
-
19
14
  def test_create_simple_geometry
20
15
  klass_ = create_ar_class
21
16
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -26,13 +21,12 @@ module RGeo
26
21
  assert_equal(::RGeo::Feature::Geometry, col_.geometric_type)
27
22
  assert_equal(true, col_.has_spatial_constraints?)
28
23
  assert_equal(false, col_.geographic?)
29
- assert_equal(if(klass_.connection.postgis_lib_version >= "2") then 0 else -1 end, col_.srid)
24
+ assert_equal(0, col_.srid)
30
25
  assert(klass_.cached_attributes.include?('latlon'))
31
26
  klass_.connection.drop_table(:spatial_test)
32
27
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
33
28
  end
34
29
 
35
-
36
30
  # no_constraints no longer supported in PostGIS 2.0
37
31
  def _test_create_no_constraints_geometry
38
32
  klass_ = create_ar_class
@@ -50,7 +44,6 @@ module RGeo
50
44
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
51
45
  end
52
46
 
53
-
54
47
  def test_create_simple_geography
55
48
  klass_ = create_ar_class
56
49
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -65,7 +58,6 @@ module RGeo
65
58
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
66
59
  end
67
60
 
68
-
69
61
  def test_create_point_geometry
70
62
  klass_ = create_ar_class
71
63
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -75,7 +67,6 @@ module RGeo
75
67
  assert(klass_.cached_attributes.include?('latlon'))
76
68
  end
77
69
 
78
-
79
70
  def test_create_geometry_with_index
80
71
  klass_ = create_ar_class
81
72
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -87,7 +78,6 @@ module RGeo
87
78
  assert(klass_.connection.indexes(:spatial_test).last.spatial)
88
79
  end
89
80
 
90
-
91
81
  def test_add_geometry_column
92
82
  klass_ = create_ar_class
93
83
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -100,7 +90,7 @@ module RGeo
100
90
  assert_equal(2, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
101
91
  cols_ = klass_.columns
102
92
  assert_equal(::RGeo::Feature::Geometry, cols_[-3].geometric_type)
103
- assert_equal(if(klass_.connection.postgis_lib_version >= "2") then 0 else -1 end, cols_[-3].srid)
93
+ assert_equal(0, cols_[-3].srid)
104
94
  assert_equal(true, cols_[-3].has_spatial_constraints?)
105
95
  assert_equal(::RGeo::Feature::Point, cols_[-2].geometric_type)
106
96
  assert_equal(4326, cols_[-2].srid)
@@ -110,7 +100,6 @@ module RGeo
110
100
  assert_equal(false, cols_[-1].has_spatial_constraints?)
111
101
  end
112
102
 
113
-
114
103
  # no_constraints no longer supported in PostGIS 2.0
115
104
  def _test_add_no_constraints_geometry_column
116
105
  klass_ = create_ar_class
@@ -124,7 +113,7 @@ module RGeo
124
113
  assert_equal(1, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
125
114
  cols_ = klass_.columns
126
115
  assert_equal(::RGeo::Feature::Geometry, cols_[-3].geometric_type)
127
- assert_equal(if(klass_.connection.postgis_lib_version >= "2") then 0 else -1 end, cols_[-3].srid)
116
+ assert_equal(0, cols_[-3].srid)
128
117
  assert_equal(true, cols_[-3].has_spatial_constraints?)
129
118
  assert_equal(::RGeo::Feature::Geometry, cols_[-2].geometric_type)
130
119
  assert_nil(cols_[-2].srid)
@@ -134,7 +123,6 @@ module RGeo
134
123
  assert_equal(false, cols_[-1].has_spatial_constraints?)
135
124
  end
136
125
 
137
-
138
126
  def test_add_geography_column
139
127
  klass_ = create_ar_class
140
128
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -147,7 +135,7 @@ module RGeo
147
135
  assert_equal(1, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
148
136
  cols_ = klass_.columns
149
137
  assert_equal(::RGeo::Feature::Geometry, cols_[-3].geometric_type)
150
- assert_equal(if(klass_.connection.postgis_lib_version >= "2") then 0 else -1 end, cols_[-3].srid)
138
+ assert_equal(0, cols_[-3].srid)
151
139
  assert_equal(true, cols_[-3].has_spatial_constraints?)
152
140
  assert_equal(::RGeo::Feature::Point, cols_[-2].geometric_type)
153
141
  assert_equal(4326, cols_[-2].srid)
@@ -157,7 +145,6 @@ module RGeo
157
145
  assert_equal(false, cols_[-1].has_spatial_constraints?)
158
146
  end
159
147
 
160
-
161
148
  def test_drop_geometry_column
162
149
  klass_ = create_ar_class
163
150
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -171,11 +158,10 @@ module RGeo
171
158
  cols_ = klass_.columns
172
159
  assert_equal(::RGeo::Feature::Geometry, cols_[-1].geometric_type)
173
160
  assert_equal('latlon', cols_[-1].name)
174
- assert_equal(if(klass_.connection.postgis_lib_version >= "2") then 0 else -1 end, cols_[-1].srid)
161
+ assert_equal(0, cols_[-1].srid)
175
162
  assert_equal(false, cols_[-1].geographic?)
176
163
  end
177
164
 
178
-
179
165
  def test_drop_geography_column
180
166
  klass_ = create_ar_class
181
167
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -196,7 +182,6 @@ module RGeo
196
182
  assert_equal(false, cols_[-2].geographic?)
197
183
  end
198
184
 
199
-
200
185
  def test_create_simple_geometry_using_shortcut
201
186
  klass_ = create_ar_class
202
187
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -206,13 +191,12 @@ module RGeo
206
191
  col_ = klass_.columns.last
207
192
  assert_equal(::RGeo::Feature::Geometry, col_.geometric_type)
208
193
  assert_equal(false, col_.geographic?)
209
- assert_equal(if(klass_.connection.postgis_lib_version >= "2") then 0 else -1 end, col_.srid)
194
+ assert_equal(0, col_.srid)
210
195
  assert(klass_.cached_attributes.include?('latlon'))
211
196
  klass_.connection.drop_table(:spatial_test)
212
197
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
213
198
  end
214
199
 
215
-
216
200
  # no_constraints no longer supported in PostGIS 2.0
217
201
  def _test_create_no_constraints_geometry_using_shortcut
218
202
  klass_ = create_ar_class
@@ -229,11 +213,9 @@ module RGeo
229
213
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
230
214
  end
231
215
 
232
-
233
216
  def test_create_simple_geography_using_shortcut
234
217
  klass_ = create_ar_class
235
218
  klass_.connection.create_table(:spatial_test) do |t_|
236
- # t_.method_missing(:geometry, 'latlon', :geographic => true)
237
219
  t_.geometry 'latlon', :geographic => true
238
220
  end
239
221
  col_ = klass_.columns.last
@@ -244,7 +226,6 @@ module RGeo
244
226
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
245
227
  end
246
228
 
247
-
248
229
  def test_create_point_geometry_using_shortcut
249
230
  klass_ = create_ar_class
250
231
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -254,7 +235,6 @@ module RGeo
254
235
  assert(klass_.cached_attributes.include?('latlon'))
255
236
  end
256
237
 
257
-
258
238
  def test_create_geometry_with_options
259
239
  klass_ = create_ar_class
260
240
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -273,7 +253,6 @@ module RGeo
273
253
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
274
254
  end
275
255
 
276
-
277
256
  def test_create_geometry_using_limit
278
257
  klass_ = create_ar_class
279
258
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -292,11 +271,8 @@ module RGeo
292
271
  assert_equal(0, klass_.connection.select_value("SELECT COUNT(*) FROM geometry_columns WHERE f_table_name='spatial_test'").to_i)
293
272
  end
294
273
 
295
-
296
274
  end
297
-
298
275
  end
299
-
300
276
  end
301
277
  end
302
278
  end
@@ -7,7 +7,7 @@ module RGeo
7
7
  module PostGISAdapter # :nodoc:
8
8
  module Tests # :nodoc:
9
9
 
10
- class TestNestedClass < ::MiniTest::Unit::TestCase # :nodoc:
10
+ class TestNestedClass < ::MiniTest::Test # :nodoc:
11
11
 
12
12
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
13
13
  OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database_local.yml'
@@ -7,7 +7,7 @@ module RGeo
7
7
  module PostGISAdapter # :nodoc:
8
8
  module Tests # :nodoc:
9
9
 
10
- class TestSpatialQueries < ::MiniTest::Unit::TestCase # :nodoc:
10
+ class TestSpatialQueries < ::MiniTest::Test # :nodoc:
11
11
 
12
12
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
13
13
  OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database_local.yml'
data/test/tc_tasks.rb CHANGED
@@ -5,7 +5,7 @@ module RGeo
5
5
  module ActiveRecord # :nodoc:
6
6
  module PostGISAdapter # :nodoc:
7
7
  module Tests # :nodoc:
8
- class TestTasks < ::MiniTest::Unit::TestCase # :nodoc:
8
+ class TestTasks < ::MiniTest::Test # :nodoc:
9
9
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
10
10
  OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database_local.yml'
11
11
 
@@ -51,7 +51,7 @@ module RGeo
51
51
  end
52
52
  ::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TestTasks.new_database_config, filename_)
53
53
  data_ = ::File.read(filename_)
54
- assert(data_.index('latlon postgis.geography(Point,4326)'))
54
+ assert(data_.index('latlon geography(Point,4326)'))
55
55
  end
56
56
 
57
57
  def test_empty_schema_dump
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgis-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.2
19
+ version: 4.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.2
26
+ version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rgeo-activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.0
33
+ version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.6.0
40
+ version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '10.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '10.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '5.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '5.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
71
  requirement: !ruby/object:Gem::Requirement