spatial_adapter 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -134,7 +134,7 @@ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
134
134
  def indexes(table_name, name = nil)
135
135
  schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',')
136
136
  result = query(<<-SQL, name)
137
- SELECT i.relname, d.indisunique, d.indkey, t.oid, am.amname
137
+ SELECT distinct i.relname, d.indisunique, d.indkey, t.oid, am.amname
138
138
  FROM pg_class t, pg_class i, pg_index d, pg_attribute a, pg_am am
139
139
  WHERE i.relkind = 'i'
140
140
  AND d.indexrelid = i.oid
data/spec/db/mysql_raw.rb CHANGED
@@ -6,10 +6,11 @@ ActiveRecord::Schema.define() do
6
6
  (
7
7
  id int(11) DEFAULT NULL auto_increment PRIMARY KEY,
8
8
  extra varchar(255),
9
+ more_extra varchar(255),
9
10
  geom point not null
10
11
  ) ENGINE=MyISAM"
11
12
  execute "create spatial index index_point_models_on_geom on point_models (geom)"
12
- execute "create index index_point_models_on_extra on point_models (extra)"
13
+ execute "create index index_point_models_on_extra on point_models (extra, more_extra)"
13
14
 
14
15
  execute "drop table if exists line_string_models"
15
16
  execute "create table line_string_models
@@ -6,11 +6,12 @@ ActiveRecord::Schema.define() do
6
6
  create table point_models
7
7
  (
8
8
  id serial primary key,
9
- extra varchar(255)
9
+ extra varchar(255),
10
+ more_extra varchar(255)
10
11
  );
11
12
  select AddGeometryColumn('point_models', 'geom', 4326, 'POINT', 2);
12
13
  create index index_point_models_on_geom on point_models using gist (geom);
13
- create index index_point_models_on_extra on point_models (extra);
14
+ create index index_point_models_on_extra on point_models (extra, more_extra);
14
15
 
15
16
  drop table if exists line_string_models;
16
17
  create table line_string_models
@@ -65,6 +65,18 @@ describe "Modified MysqlAdapter" do
65
65
  @indexes = @connection.indexes('point_models')
66
66
  end
67
67
 
68
+ it "should return an IndexDefinition for each index on the table" do
69
+ @indexes.should have(2).items
70
+ @indexes.each do |i|
71
+ i.should be_a(ActiveRecord::ConnectionAdapters::IndexDefinition)
72
+ end
73
+ end
74
+
75
+ it "should indicate the correct columns in the index" do
76
+ @indexes.select{|i| i.name == 'index_point_models_on_geom'}.first.columns.should == ['geom']
77
+ @indexes.select{|i| i.name == 'index_point_models_on_extra'}.first.columns.should == ['extra', 'more_extra']
78
+ end
79
+
68
80
  it "should be marked as spatial if a spatial index" do
69
81
  @indexes.select{|i| i.columns.include?('geom')}.first.spatial.should == true
70
82
  end
@@ -124,12 +124,24 @@ describe "Modified PostgreSQLAdapter" do
124
124
  @indexes = @connection.indexes('point_models', 'index_point_models_on_geom')
125
125
  end
126
126
 
127
+ it "should return an IndexDefinition for each index on the table" do
128
+ @indexes.should have(2).items
129
+ @indexes.each do |i|
130
+ i.should be_a(ActiveRecord::ConnectionAdapters::IndexDefinition)
131
+ end
132
+ end
133
+
134
+ it "should indicate the correct columns in the index" do
135
+ @indexes.select{|i| i.name == 'index_point_models_on_geom'}.first.columns.should == ['geom']
136
+ @indexes.select{|i| i.name == 'index_point_models_on_extra'}.first.columns.should == ['extra', 'more_extra']
137
+ end
138
+
127
139
  it "should be marked as spatial if a GIST index" do
128
- @indexes.select{|i| i.columns.include?('geom')}.first.spatial.should == true
140
+ @indexes.select{|i| i.name == 'index_point_models_on_geom'}.first.spatial.should == true
129
141
  end
130
142
 
131
143
  it "should not be marked as spatial if not a GIST index" do
132
- @indexes.select{|i| i.columns.include?('extra')}.first.spatial.should == false
144
+ @indexes.select{|i| i.name == 'index_point_models_on_extra'}.first.spatial.should == false
133
145
  end
134
146
  end
135
147
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spatial_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Deffendol
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-18 00:00:00 -07:00
12
+ date: 2010-02-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency