spatial_adapter 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -2
- data/VERSION +1 -1
- data/lib/spatial_adapter/postgresql.rb +1 -1
- data/rails/init.rb +1 -1
- data/spec/postgresql/migration_spec.rb +20 -6
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -28,9 +28,13 @@ dependencies as well.
|
|
28
28
|
|
29
29
|
gem install spatial_adapter
|
30
30
|
|
31
|
-
In a Rails app, you can add a gem dependency in environment.rb:
|
31
|
+
In a Rails 2.x app, you can add a gem dependency in environment.rb:
|
32
32
|
|
33
|
-
config.gem
|
33
|
+
config.gem 'spatial_adapter'
|
34
|
+
|
35
|
+
In a Rails 3 app, add a gem dependency to Gemfile:
|
36
|
+
|
37
|
+
gem 'spatial_adapter'
|
34
38
|
|
35
39
|
=== As a Rails Plugin
|
36
40
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
@@ -99,7 +99,7 @@ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
|
|
99
99
|
columns(table_name).each do |col|
|
100
100
|
if column_names.include?(col.name.to_sym)
|
101
101
|
# Geometry columns have to be removed using DropGeometryColumn
|
102
|
-
if col.spatial? && !col.geographic?
|
102
|
+
if col.is_a?(SpatialColumn) && col.spatial? && !col.geographic?
|
103
103
|
execute "SELECT DropGeometryColumn('#{table_name}','#{col.name}')"
|
104
104
|
else
|
105
105
|
original_remove_column(table_name, col.name)
|
data/rails/init.rb
CHANGED
@@ -330,22 +330,36 @@ describe "Spatially-enabled Migrations" do
|
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|
333
|
+
SpatialAdapter.geometry_data_types.keys.each do |type|
|
334
|
+
it "should remove #{type.to_s} geography columns using ALTER TABLE DROP COLUMN" do
|
335
|
+
ActiveRecord::Schema.define do
|
336
|
+
create_table :migrated_geometry_models, :force => true do |t|
|
337
|
+
t.integer :extra
|
338
|
+
t.send(type, :geom, :geographic => true)
|
339
|
+
end
|
340
|
+
end
|
333
341
|
|
334
|
-
|
335
|
-
|
342
|
+
@connection.should_receive(:execute).with(/alter table.*migrated_geometry_models.*drop.*geom/i)
|
343
|
+
ActiveRecord::Schema.define do
|
344
|
+
remove_column :migrated_geometry_models, :geom
|
345
|
+
end
|
346
|
+
@connection.should_receive(:execute).with(anything())
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
it "should still remove non-spatial columns using ALTER TABLE DROP COLUMN" do
|
336
351
|
ActiveRecord::Schema.define do
|
337
352
|
create_table :migrated_geometry_models, :force => true do |t|
|
338
353
|
t.integer :extra
|
339
|
-
t.
|
354
|
+
t.point :geom
|
340
355
|
end
|
341
356
|
end
|
342
357
|
|
343
|
-
@connection.should_receive(:execute).with(/alter table.*migrated_geometry_models.*drop.*
|
358
|
+
@connection.should_receive(:execute).with(/alter table.*migrated_geometry_models.*drop.*extra/i)
|
344
359
|
ActiveRecord::Schema.define do
|
345
|
-
remove_column :migrated_geometry_models, :
|
360
|
+
remove_column :migrated_geometry_models, :extra
|
346
361
|
end
|
347
362
|
@connection.should_receive(:execute).with(anything())
|
348
363
|
end
|
349
364
|
end
|
350
|
-
end
|
351
365
|
end
|