activerecord-spatial 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +3314 -1052
- data/.travis.yml +17 -0
- data/Gemfile +1 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +6 -12
- data/activerecord-spatial.gemspec +1 -1
- data/lib/activerecord-spatial.rb +1 -0
- data/lib/activerecord-spatial/active_record.rb +1 -0
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions.rb +1 -0
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions/active_record.rb +4 -3
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/postgis.rb +1 -0
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/unknown_srid.rb +2 -1
- data/lib/activerecord-spatial/active_record/models/geography_column.rb +1 -0
- data/lib/activerecord-spatial/active_record/models/geometry_column.rb +1 -0
- data/lib/activerecord-spatial/active_record/models/spatial_column.rb +1 -0
- data/lib/activerecord-spatial/active_record/models/spatial_ref_sys.rb +1 -0
- data/lib/activerecord-spatial/associations.rb +4 -12
- data/lib/activerecord-spatial/associations/active_record.rb +96 -54
- data/lib/activerecord-spatial/associations/base.rb +2 -19
- data/lib/activerecord-spatial/associations/reflection/spatial_reflection.rb +1 -0
- data/lib/activerecord-spatial/associations/spatial_association.rb +41 -0
- data/lib/activerecord-spatial/spatial_columns.rb +1 -0
- data/lib/activerecord-spatial/spatial_function.rb +2 -1
- data/lib/activerecord-spatial/spatial_scope_constants.rb +1 -0
- data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_0.rb +1 -0
- data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_2.rb +1 -0
- data/lib/activerecord-spatial/spatial_scope_constants/postgis_legacy.rb +1 -0
- data/lib/activerecord-spatial/spatial_scopes.rb +14 -13
- data/lib/activerecord-spatial/version.rb +2 -1
- data/test/accessors_geographies_tests.rb +2 -1
- data/test/accessors_geometries_tests.rb +2 -1
- data/test/adapter_tests.rb +5 -4
- data/test/associations_tests.rb +40 -25
- data/test/geography_column_tests.rb +2 -1
- data/test/geometry_column_tests.rb +2 -1
- data/test/models/bar.rb +1 -9
- data/test/models/blort.rb +1 -7
- data/test/models/foo.rb +3 -9
- data/test/models/foo3d.rb +1 -9
- data/test/models/foo_geography.rb +1 -8
- data/test/models/zortable.rb +1 -9
- data/test/schema.rb +54 -0
- data/test/spatial_function_tests.rb +2 -1
- data/test/spatial_scopes_geographies_tests.rb +2 -1
- data/test/spatial_scopes_tests.rb +2 -1
- data/test/test_helper.rb +57 -91
- metadata +9 -7
- data/lib/activerecord-spatial/associations/preloader/spatial_association.rb +0 -57
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-spatial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.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: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: geos-extensions
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,6 +47,7 @@ extra_rdoc_files:
|
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
49
|
- ".rubocop.yml"
|
50
|
+
- ".travis.yml"
|
50
51
|
- Gemfile
|
51
52
|
- Guardfile
|
52
53
|
- MIT-LICENSE
|
@@ -66,8 +67,8 @@ files:
|
|
66
67
|
- lib/activerecord-spatial/associations.rb
|
67
68
|
- lib/activerecord-spatial/associations/active_record.rb
|
68
69
|
- lib/activerecord-spatial/associations/base.rb
|
69
|
-
- lib/activerecord-spatial/associations/preloader/spatial_association.rb
|
70
70
|
- lib/activerecord-spatial/associations/reflection/spatial_reflection.rb
|
71
|
+
- lib/activerecord-spatial/associations/spatial_association.rb
|
71
72
|
- lib/activerecord-spatial/spatial_columns.rb
|
72
73
|
- lib/activerecord-spatial/spatial_function.rb
|
73
74
|
- lib/activerecord-spatial/spatial_scope_constants.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- test/models/foo3d.rb
|
98
99
|
- test/models/foo_geography.rb
|
99
100
|
- test/models/zortable.rb
|
101
|
+
- test/schema.rb
|
100
102
|
- test/spatial_function_tests.rb
|
101
103
|
- test/spatial_scopes_geographies_tests.rb
|
102
104
|
- test/spatial_scopes_tests.rb
|
@@ -120,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
122
|
- !ruby/object:Gem::Version
|
121
123
|
version: '0'
|
122
124
|
requirements: []
|
123
|
-
|
124
|
-
rubygems_version: 2.6.11
|
125
|
+
rubygems_version: 3.0.3
|
125
126
|
signing_key:
|
126
127
|
specification_version: 4
|
127
128
|
summary: ActiveRecord Spatial gives AR the ability to work with PostGIS columns.
|
@@ -146,6 +147,7 @@ test_files:
|
|
146
147
|
- test/models/foo3d.rb
|
147
148
|
- test/models/foo_geography.rb
|
148
149
|
- test/models/zortable.rb
|
150
|
+
- test/schema.rb
|
149
151
|
- test/spatial_function_tests.rb
|
150
152
|
- test/spatial_scopes_geographies_tests.rb
|
151
153
|
- test/spatial_scopes_tests.rb
|
@@ -1,57 +0,0 @@
|
|
1
|
-
|
2
|
-
module ActiveRecord
|
3
|
-
module Associations
|
4
|
-
class Preloader #:nodoc:
|
5
|
-
class SpatialAssociation < HasMany #:nodoc:
|
6
|
-
if method_defined?(:query_scope)
|
7
|
-
def query_scope(ids)
|
8
|
-
spatial_query_scope(ids)
|
9
|
-
end
|
10
|
-
else
|
11
|
-
def records_for(ids)
|
12
|
-
spatial_query_scope(ids)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def association_key_name
|
19
|
-
SPATIAL_FIELD_ALIAS
|
20
|
-
end
|
21
|
-
|
22
|
-
def spatial_query_scope(ids)
|
23
|
-
join_name = model.quoted_table_name
|
24
|
-
column = %{#{SPATIAL_JOIN_QUOTED_NAME}.#{model.quoted_primary_key}}
|
25
|
-
geom = {
|
26
|
-
class: model,
|
27
|
-
table_alias: SPATIAL_JOIN_NAME
|
28
|
-
}
|
29
|
-
|
30
|
-
if reflection.options[:geom].is_a?(Hash)
|
31
|
-
geom.merge!(reflection.options[:geom])
|
32
|
-
else
|
33
|
-
geom[:column] = reflection.options[:geom]
|
34
|
-
end
|
35
|
-
|
36
|
-
where_function = klass.send(
|
37
|
-
"st_#{reflection.options[:relationship]}",
|
38
|
-
geom,
|
39
|
-
(reflection.options[:scope_options] || {}).merge(
|
40
|
-
column: reflection.options[:foreign_geom]
|
41
|
-
)
|
42
|
-
)
|
43
|
-
|
44
|
-
scope.
|
45
|
-
select(%{#{klass.quoted_table_name}.*, array_to_string(array_agg(#{column}), ',') AS "#{SPATIAL_FIELD_ALIAS}"}).
|
46
|
-
joins(
|
47
|
-
"INNER JOIN #{join_name} AS #{SPATIAL_JOIN_QUOTED_NAME} ON (" <<
|
48
|
-
where_function.where_clause.send(:predicates).join(' AND ') <<
|
49
|
-
')'
|
50
|
-
).
|
51
|
-
where(model.arel_table.alias(SPATIAL_JOIN_NAME)[model.primary_key].in(ids)).
|
52
|
-
group(table[klass.primary_key])
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|