rs_spatial_adapter 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +197 -0
- data/VERSION +1 -0
- data/lib/spatial_adapter.rb +41 -0
- data/lib/spatial_adapter/common/raw_geom_info.rb +23 -0
- data/lib/spatial_adapter/common/schema_definitions.rb +11 -0
- data/lib/spatial_adapter/common/schema_dumper.rb +136 -0
- data/lib/spatial_adapter/common/spatial_column.rb +70 -0
- data/lib/spatial_adapter/common/table_definition.rb +14 -0
- data/lib/spatial_adapter/mysql.rb +98 -0
- data/lib/spatial_adapter/mysql2.rb +97 -0
- data/lib/spatial_adapter/postgresql.rb +388 -0
- data/lib/spatial_adapter/railtie.rb +13 -0
- data/rails/init.rb +11 -0
- data/spec/README.txt +22 -0
- data/spec/db/mysql2_raw.rb +70 -0
- data/spec/db/mysql_raw.rb +70 -0
- data/spec/db/postgis_raw.rb +190 -0
- data/spec/models/common.rb +65 -0
- data/spec/mysql/connection_adapter_spec.rb +106 -0
- data/spec/mysql/migration_spec.rb +64 -0
- data/spec/mysql/models_spec.rb +65 -0
- data/spec/mysql/schema_dumper_spec.rb +56 -0
- data/spec/mysql2/connection_adapter_spec.rb +106 -0
- data/spec/mysql2/migration_spec.rb +64 -0
- data/spec/mysql2/models_spec.rb +65 -0
- data/spec/mysql2/schema_dumper_spec.rb +56 -0
- data/spec/postgresql/connection_adapter_spec.rb +227 -0
- data/spec/postgresql/migration_spec.rb +365 -0
- data/spec/postgresql/models_spec.rb +221 -0
- data/spec/postgresql/schema_dumper_spec.rb +79 -0
- data/spec/shared_examples.rb +43 -0
- data/spec/spec_helper.rb +90 -0
- metadata +131 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spatial_adapter/mysql'
|
3
|
+
require 'db/mysql_raw'
|
4
|
+
require 'models/common'
|
5
|
+
|
6
|
+
describe "Modified MysqlAdapter" do
|
7
|
+
before :each do
|
8
|
+
mysql_connection
|
9
|
+
@connection = ActiveRecord::Base.connection
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#supports_geographic?' do
|
13
|
+
it "should be false" do
|
14
|
+
@connection.supports_geographic?.should == false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#columns" do
|
19
|
+
describe "type" do
|
20
|
+
it "should be SpatialMysqlColumn if column is a spatial data type" do
|
21
|
+
PointModel.columns.select{|c| c.name == 'geom'}.first.should be_a(ActiveRecord::ConnectionAdapters::SpatialMysqlColumn)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be SpatialMysqlColumn if column is not a spatial data type" do
|
25
|
+
PointModel.columns.select{|c| c.name == 'extra'}.first.should be_a(ActiveRecord::ConnectionAdapters::MysqlColumn)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "@geometry_type" do
|
30
|
+
it "should be :point for columns restricted to POINT types" do
|
31
|
+
PointModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :point
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be :line_string for columns restricted to LINESTRING types" do
|
35
|
+
LineStringModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :line_string
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be :polygon for columns restricted to POLYGON types" do
|
39
|
+
PolygonModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :polygon
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be :multi_point for columns restricted to MULTIPOINT types" do
|
43
|
+
MultiPointModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :multi_point
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be :multi_line_string for columns restricted to MULTILINESTRING types" do
|
47
|
+
MultiLineStringModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :multi_line_string
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be :multi_polygon for columns restricted to MULTIPOLYGON types" do
|
51
|
+
MultiPolygonModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :multi_polygon
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be :geometry_collection for columns restricted to GEOMETRYCOLLECTION types" do
|
55
|
+
GeometryCollectionModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :geometry_collection
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be :geometry for columns not restricted to a type" do
|
59
|
+
GeometryModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :geometry
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#indexes" do
|
65
|
+
before :each do
|
66
|
+
@indexes = @connection.indexes('point_models')
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should return an IndexDefinition for each index on the table" do
|
70
|
+
@indexes.should have(2).items
|
71
|
+
@indexes.each do |i|
|
72
|
+
i.should be_a(ActiveRecord::ConnectionAdapters::IndexDefinition)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should indicate the correct columns in the index" do
|
77
|
+
@indexes.select{|i| i.name == 'index_point_models_on_geom'}.first.columns.should == ['geom']
|
78
|
+
@indexes.select{|i| i.name == 'index_point_models_on_extra'}.first.columns.should == ['extra', 'more_extra']
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should be marked as spatial if a spatial index" do
|
82
|
+
@indexes.select{|i| i.columns.include?('geom')}.first.spatial.should == true
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not be marked as spatial if not a spatial index" do
|
86
|
+
@indexes.select{|i| i.columns.include?('extra')}.first.spatial.should == false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#add_index" do
|
91
|
+
after :each do
|
92
|
+
@connection.should_receive(:execute).with(any_args())
|
93
|
+
@connection.remove_index('geometry_models', 'geom')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should create a spatial index given :spatial => true" do
|
97
|
+
@connection.should_receive(:execute).with(/create spatial index/i)
|
98
|
+
@connection.add_index('geometry_models', 'geom', :spatial => true)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should not create a spatial index unless specified" do
|
102
|
+
@connection.should_not_receive(:execute).with(/create spatial index/i)
|
103
|
+
@connection.add_index('geometry_models', 'extra')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spatial_adapter/mysql'
|
3
|
+
|
4
|
+
class MigratedGeometryModel < ActiveRecord::Base
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Spatially-enabled Migrations" do
|
8
|
+
before :each do
|
9
|
+
mysql_connection
|
10
|
+
@connection = ActiveRecord::Base.connection
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "creating tables" do
|
14
|
+
after :each do
|
15
|
+
@connection.drop_table "migrated_geometry_models"
|
16
|
+
end
|
17
|
+
|
18
|
+
SpatialAdapter.geometry_data_types.keys.each do |type|
|
19
|
+
it "should create #{type.to_s} columns" do
|
20
|
+
ActiveRecord::Schema.define do
|
21
|
+
create_table :migrated_geometry_models, :force => true do |t|
|
22
|
+
t.integer :extra
|
23
|
+
t.send(type, :geom)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
geom_column = @connection.columns(:migrated_geometry_models).select{|c| c.name == 'geom'}.first
|
28
|
+
geom_column.should be_a(SpatialAdapter::SpatialColumn)
|
29
|
+
geom_column.geometry_type.should == type
|
30
|
+
geom_column.type.should == :string
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "adding columns" do
|
36
|
+
before :each do
|
37
|
+
ActiveRecord::Schema.define do
|
38
|
+
create_table :migrated_geometry_models, :force => true do |t|
|
39
|
+
t.integer :extra
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
after :each do
|
45
|
+
@connection.drop_table "migrated_geometry_models"
|
46
|
+
end
|
47
|
+
|
48
|
+
SpatialAdapter.geometry_data_types.keys.each do |type|
|
49
|
+
it "should add #{type.to_s} columns" do
|
50
|
+
ActiveRecord::Schema.define do
|
51
|
+
add_column :migrated_geometry_models, :geom, type
|
52
|
+
end
|
53
|
+
|
54
|
+
geom_column = @connection.columns(:migrated_geometry_models).select{|c| c.name == 'geom'}.first
|
55
|
+
geom_column.should be_a(SpatialAdapter::SpatialColumn)
|
56
|
+
geom_column.geometry_type.should == type
|
57
|
+
geom_column.type.should == :string
|
58
|
+
geom_column.with_z.should == false
|
59
|
+
geom_column.with_m.should == false
|
60
|
+
geom_column.srid.should == -1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared_examples'
|
3
|
+
require 'spatial_adapter/mysql'
|
4
|
+
require 'db/mysql_raw'
|
5
|
+
require 'models/common'
|
6
|
+
|
7
|
+
describe "Spatially-enabled Models" do
|
8
|
+
before :each do
|
9
|
+
mysql_connection
|
10
|
+
@connection = ActiveRecord::Base.connection
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "inserting records" do
|
14
|
+
it 'should save Point objects' do
|
15
|
+
model = PointModel.new(:extra => 'test', :geom => GeometryFactory.point)
|
16
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.point.as_hex_wkb), anything(), anything(), anything(), anything())
|
17
|
+
model.save.should == true
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should save LineString objects' do
|
21
|
+
model = LineStringModel.new(:extra => 'test', :geom => GeometryFactory.line_string)
|
22
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.line_string.as_hex_wkb), anything(), anything(), anything(), anything())
|
23
|
+
model.save.should == true
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should save Polygon objects' do
|
27
|
+
model = PolygonModel.new(:extra => 'test', :geom => GeometryFactory.polygon)
|
28
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.polygon.as_hex_wkb), anything(), anything(), anything(), anything())
|
29
|
+
model.save.should == true
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should save MultiPoint objects' do
|
33
|
+
model = MultiPointModel.new(:extra => 'test', :geom => GeometryFactory.multi_point)
|
34
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.multi_point.as_hex_wkb), anything(), anything(), anything(), anything())
|
35
|
+
model.save.should == true
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should save MultiLineString objects' do
|
39
|
+
model = MultiLineStringModel.new(:extra => 'test', :geom => GeometryFactory.multi_line_string)
|
40
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.multi_line_string.as_hex_wkb), anything(), anything(), anything(), anything())
|
41
|
+
model.save.should == true
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should save MultiPolygon objects' do
|
45
|
+
model = MultiPolygonModel.new(:extra => 'test', :geom => GeometryFactory.multi_polygon)
|
46
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.multi_polygon.as_hex_wkb), anything(), anything(), anything(), anything())
|
47
|
+
model.save.should == true
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should save GeometryCollection objects' do
|
51
|
+
model = GeometryCollectionModel.new(:extra => 'test', :geom => GeometryFactory.geometry_collection)
|
52
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.geometry_collection.as_hex_wkb), anything(), anything(), anything(), anything())
|
53
|
+
model.save.should == true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should save Geometry objects' do
|
57
|
+
model = GeometryModel.new(:extra => 'test', :geom => GeometryFactory.point)
|
58
|
+
@connection.should_receive(:insert_sql).with(Regexp.new(GeometryFactory.point.as_hex_wkb), anything(), anything(), anything(), anything())
|
59
|
+
model.save.should == true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
include CommonModelActions
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spatial_adapter/mysql'
|
3
|
+
|
4
|
+
describe "Spatially-enabled Schema Dumps" do
|
5
|
+
before :all do
|
6
|
+
mysql_connection
|
7
|
+
@connection = ActiveRecord::Base.connection
|
8
|
+
|
9
|
+
# Create a new table
|
10
|
+
ActiveRecord::Schema.define do
|
11
|
+
create_table :migrated_geometry_models, :options=> "ENGINE=MyISAM", :force => true do |t|
|
12
|
+
t.integer :extra
|
13
|
+
t.point :geom, :null => false
|
14
|
+
end
|
15
|
+
add_index :migrated_geometry_models, :geom, :spatial => true, :name => 'test_spatial_index'
|
16
|
+
end
|
17
|
+
|
18
|
+
File.open('schema.rb', "w") do |file|
|
19
|
+
ActiveRecord::SchemaDumper.dump(@connection, file)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Drop the original table
|
23
|
+
@connection.drop_table "migrated_geometry_models"
|
24
|
+
|
25
|
+
# Load the dumped schema
|
26
|
+
load('schema.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
after :all do
|
30
|
+
# delete the schema file
|
31
|
+
File.delete('schema.rb')
|
32
|
+
|
33
|
+
# Drop the new table
|
34
|
+
@connection.drop_table "migrated_geometry_models"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should preserve spatial attributes of tables" do
|
38
|
+
columns = @connection.columns("migrated_geometry_models")
|
39
|
+
|
40
|
+
columns.should have(3).items
|
41
|
+
geom_column = columns.select{|c| c.name == 'geom'}.first
|
42
|
+
geom_column.should be_a(SpatialAdapter::SpatialColumn)
|
43
|
+
geom_column.geometry_type.should == :point
|
44
|
+
geom_column.type.should == :string
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should preserve spatial indexes" do
|
48
|
+
indexes = @connection.indexes("migrated_geometry_models")
|
49
|
+
|
50
|
+
indexes.should have(1).item
|
51
|
+
|
52
|
+
indexes.first.name.should == 'test_spatial_index'
|
53
|
+
indexes.first.columns.should == ["geom"]
|
54
|
+
indexes.first.spatial.should == true
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spatial_adapter/mysql2'
|
3
|
+
require 'db/mysql2_raw'
|
4
|
+
require 'models/common'
|
5
|
+
|
6
|
+
describe "Modified Mysql2Adapter" do
|
7
|
+
before :each do
|
8
|
+
mysql2_connection
|
9
|
+
@connection = ActiveRecord::Base.connection
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#supports_geographic?' do
|
13
|
+
it "should be false" do
|
14
|
+
@connection.supports_geographic?.should == false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#columns" do
|
19
|
+
describe "type" do
|
20
|
+
it "should be SpatialMysql2Column if column is a spatial data type" do
|
21
|
+
PointModel.columns.select{|c| c.name == 'geom'}.first.should be_a(ActiveRecord::ConnectionAdapters::SpatialMysql2Column)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be Mysql2Column if column is not a spatial data type" do
|
25
|
+
PointModel.columns.select{|c| c.name == 'extra'}.first.should be_a(ActiveRecord::ConnectionAdapters::Mysql2Column)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "@geometry_type" do
|
30
|
+
it "should be :point for columns restricted to POINT types" do
|
31
|
+
PointModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :point
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be :line_string for columns restricted to LINESTRING types" do
|
35
|
+
LineStringModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :line_string
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be :polygon for columns restricted to POLYGON types" do
|
39
|
+
PolygonModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :polygon
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be :multi_point for columns restricted to MULTIPOINT types" do
|
43
|
+
MultiPointModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :multi_point
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be :multi_line_string for columns restricted to MULTILINESTRING types" do
|
47
|
+
MultiLineStringModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :multi_line_string
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be :multi_polygon for columns restricted to MULTIPOLYGON types" do
|
51
|
+
MultiPolygonModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :multi_polygon
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be :geometry_collection for columns restricted to GEOMETRYCOLLECTION types" do
|
55
|
+
GeometryCollectionModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :geometry_collection
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be :geometry for columns not restricted to a type" do
|
59
|
+
GeometryModel.columns.select{|c| c.name == 'geom'}.first.geometry_type.should == :geometry
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#indexes" do
|
65
|
+
before :each do
|
66
|
+
@indexes = @connection.indexes('point_models')
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should return an IndexDefinition for each index on the table" do
|
70
|
+
@indexes.should have(2).items
|
71
|
+
@indexes.each do |i|
|
72
|
+
i.should be_a(ActiveRecord::ConnectionAdapters::IndexDefinition)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should indicate the correct columns in the index" do
|
77
|
+
@indexes.select{|i| i.name == 'index_point_models_on_geom'}.first.columns.should == ['geom']
|
78
|
+
@indexes.select{|i| i.name == 'index_point_models_on_extra'}.first.columns.should == ['extra', 'more_extra']
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should be marked as spatial if a spatial index" do
|
82
|
+
@indexes.select{|i| i.columns.include?('geom')}.first.spatial.should == true
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not be marked as spatial if not a spatial index" do
|
86
|
+
@indexes.select{|i| i.columns.include?('extra')}.first.spatial.should == false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#add_index" do
|
91
|
+
after :each do
|
92
|
+
@connection.should_receive(:execute).with(any_args())
|
93
|
+
@connection.remove_index('geometry_models', 'geom')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should create a spatial index given :spatial => true" do
|
97
|
+
@connection.should_receive(:execute).with(/create spatial index/i)
|
98
|
+
@connection.add_index('geometry_models', 'geom', :spatial => true)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should not create a spatial index unless specified" do
|
102
|
+
@connection.should_not_receive(:execute).with(/create spatial index/i)
|
103
|
+
@connection.add_index('geometry_models', 'extra')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spatial_adapter/mysql2'
|
3
|
+
|
4
|
+
class MigratedGeometryModel < ActiveRecord::Base
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Spatially-enabled Migrations" do
|
8
|
+
before :each do
|
9
|
+
mysql2_connection
|
10
|
+
@connection = ActiveRecord::Base.connection
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "creating tables" do
|
14
|
+
after :each do
|
15
|
+
@connection.drop_table "migrated_geometry_models"
|
16
|
+
end
|
17
|
+
|
18
|
+
SpatialAdapter.geometry_data_types.keys.each do |type|
|
19
|
+
it "should create #{type.to_s} columns" do
|
20
|
+
ActiveRecord::Schema.define do
|
21
|
+
create_table :migrated_geometry_models, :force => true do |t|
|
22
|
+
t.integer :extra
|
23
|
+
t.send(type, :geom)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
geom_column = @connection.columns(:migrated_geometry_models).select{|c| c.name == 'geom'}.first
|
28
|
+
geom_column.should be_a(SpatialAdapter::SpatialColumn)
|
29
|
+
geom_column.geometry_type.should == type
|
30
|
+
geom_column.type.should == :string
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "adding columns" do
|
36
|
+
before :each do
|
37
|
+
ActiveRecord::Schema.define do
|
38
|
+
create_table :migrated_geometry_models, :force => true do |t|
|
39
|
+
t.integer :extra
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
after :each do
|
45
|
+
@connection.drop_table "migrated_geometry_models"
|
46
|
+
end
|
47
|
+
|
48
|
+
SpatialAdapter.geometry_data_types.keys.each do |type|
|
49
|
+
it "should add #{type.to_s} columns" do
|
50
|
+
ActiveRecord::Schema.define do
|
51
|
+
add_column :migrated_geometry_models, :geom, type
|
52
|
+
end
|
53
|
+
|
54
|
+
geom_column = @connection.columns(:migrated_geometry_models).select{|c| c.name == 'geom'}.first
|
55
|
+
geom_column.should be_a(SpatialAdapter::SpatialColumn)
|
56
|
+
geom_column.geometry_type.should == type
|
57
|
+
geom_column.type.should == :string
|
58
|
+
geom_column.with_z.should == false
|
59
|
+
geom_column.with_m.should == false
|
60
|
+
geom_column.srid.should == -1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|