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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5da85e153ac728aed4dd05c63c31db2b8408db33
4
- data.tar.gz: e1fb8123e8ac236ff5299d19f691147a510f9d22
3
+ metadata.gz: 4134b225eb23433b9805a83ec978ae7fe5c9ee5b
4
+ data.tar.gz: 7cd3ca0bea4ccd9c6b51a0e6eb646e82acc55eb0
5
5
  SHA512:
6
- metadata.gz: b6af550d08c16c0eff95249fc80e08eb9aabf59e1cfac0c163edd43506ee6c6887b6acba7e7eac4f6ca3f63a6052f4479ba3337c48c4cbdfce88d21cf0874de8
7
- data.tar.gz: 9bbe835d52ed5d41f91c1d22e58564775f7c200d52ea772a7818c9987456949fbffa7393e81ad20acec16edd6ccae52b1b95363f3403a920e046f810e3451ee6
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 binary?(string)
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 binary?(string)
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
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  module PostGISAdapter
4
- VERSION = '3.0.0.beta1'.freeze
4
+ VERSION = '3.0.0.beta2'.freeze
5
5
  end
6
6
  end
7
7
  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.beta1
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-09 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord