activerecord-postgis-adapter 3.0.0.beta1 → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/postgis_adapter/oid/spatial.rb +2 -2
- data/lib/active_record/connection_adapters/postgis_adapter/spatial_column.rb +8 -1
- data/lib/active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb +4 -3
- data/lib/active_record/connection_adapters/postgis_adapter/version.rb +1 -1
- data/test/ddl_test.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4134b225eb23433b9805a83ec978ae7fe5c9ee5b
|
4
|
+
data.tar.gz: 7cd3ca0bea4ccd9c6b51a0e6eb646e82acc55eb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fff96e4437bda957061ef02a4ef9bcb7bd34463387947f39f4de46efddd00212724f54977460f6e796f938b51ef0ae840fde8f45df974a61f048d9304c05cd4f
|
7
|
+
data.tar.gz: ed3977486ef32fe77dc7e62bbfff5ed96af537f8f6c9509218a3ea3cb25770d5e05d86fa57b006fce32a65994185b951f8287b1a03f92d572684ed2aa304a6c3
|
@@ -100,12 +100,12 @@ module ActiveRecord
|
|
100
100
|
nil
|
101
101
|
end
|
102
102
|
|
103
|
-
def
|
103
|
+
def binary_string?(string)
|
104
104
|
string[0] == "\x00" || string[0] == "\x01" || string[0, 4] =~ /[0-9a-fA-F]{4}/
|
105
105
|
end
|
106
106
|
|
107
107
|
def wkt_parser(factory, string)
|
108
|
-
if
|
108
|
+
if binary_string?(string)
|
109
109
|
RGeo::WKRep::WKBParser.new(factory, support_ewkb: true, default_srid: @srid)
|
110
110
|
else
|
111
111
|
RGeo::WKRep::WKTParser.new(factory, support_ewkt: true, default_srid: @srid)
|
@@ -44,13 +44,20 @@ module ActiveRecord # :nodoc:
|
|
44
44
|
:geometric_type,
|
45
45
|
:has_m,
|
46
46
|
:has_z,
|
47
|
-
:limit, # override
|
48
47
|
:srid
|
49
48
|
|
50
49
|
alias :geographic? :geographic
|
51
50
|
alias :has_z? :has_z
|
52
51
|
alias :has_m? :has_m
|
53
52
|
|
53
|
+
def limit
|
54
|
+
if spatial?
|
55
|
+
@limit
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
54
61
|
def spatial?
|
55
62
|
cast_type.respond_to?(:spatial?) && cast_type.spatial?
|
56
63
|
end
|
@@ -12,14 +12,15 @@ module ActiveRecord # :nodoc:
|
|
12
12
|
# super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L320
|
13
13
|
def new_column_definition(name, type, options)
|
14
14
|
if (info = MainAdapter.spatial_column_options(type.to_sym))
|
15
|
+
if (limit = options.delete(:limit))
|
16
|
+
options.merge!(limit) if limit.is_a?(::Hash)
|
17
|
+
end
|
18
|
+
|
15
19
|
geo_type = ColumnDefinition.geo_type(options[:type] || type || info[:type])
|
16
20
|
base_type = info[:type] || (options[:geographic] ? :geography : :geometry)
|
17
21
|
|
18
22
|
# puts name.dup << " - " << type.to_s << " - " << options.to_s << " :: " << geo_type.to_s << " - " << base_type.to_s
|
19
23
|
|
20
|
-
if (limit = options.delete(:limit))
|
21
|
-
options.merge!(limit) if limit.is_a?(::Hash)
|
22
|
-
end
|
23
24
|
if options[:geographic]
|
24
25
|
options[:limit] = ColumnDefinition.options_to_limit(geo_type, options)
|
25
26
|
end
|
data/test/ddl_test.rb
CHANGED
@@ -270,6 +270,24 @@ class DDLTest < ActiveSupport::TestCase # :nodoc:
|
|
270
270
|
assert_equal false, klass.columns[-1].array
|
271
271
|
end
|
272
272
|
|
273
|
+
def test_reload_dumped_schema
|
274
|
+
klass.connection.create_table(:spatial_models, force: true) do |t|
|
275
|
+
t.geography "latlon1", limit: {:srid=>4326, :type=>"point", :geographic=>true}
|
276
|
+
end
|
277
|
+
klass.reset_column_information
|
278
|
+
col = klass.columns.last
|
279
|
+
assert_equal 4326, col.srid
|
280
|
+
end
|
281
|
+
|
282
|
+
def test_non_spatial_column_limits
|
283
|
+
klass.connection.create_table(:spatial_models, force: true) do |t|
|
284
|
+
t.string :foo, limit: 123
|
285
|
+
end
|
286
|
+
klass.reset_column_information
|
287
|
+
col = klass.columns.last
|
288
|
+
assert_equal 123, col.limit
|
289
|
+
end
|
290
|
+
|
273
291
|
private
|
274
292
|
|
275
293
|
def klass
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-postgis-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma, Tee Parham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|