activerecord-postgis-adapter 8.0.3 → 9.0.1

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
  SHA256:
3
- metadata.gz: a24c165231e4b03b66bac3cc34446bc6683e960a7cfc5dd0e9cdc83aa9662b81
4
- data.tar.gz: 1f8267c7469590eb14e12312e311e195c87504d3a1a64a9fe79392d50a9dab2f
3
+ metadata.gz: 1431c8f09469d4559144c63ce0d279428e605dee782e1f124bdcb548a43e2453
4
+ data.tar.gz: 1d881e51d00762d2386f6caffd034574f8520f8b0f555657bf84fd2bc42b1137
5
5
  SHA512:
6
- metadata.gz: 976f8ee3f628fcacffea4e7890f5c4f29d2308c3aa28bb070d7d547931767dce49438286f0be1dcb1424b9e3f38f5fb260f6c51750062755b0124416f5387064
7
- data.tar.gz: 2012d45e2fb4603c11657a9a7d9a907d93e3202200eddc990bedd1a6a0e73680d9064838d248dabbc7c244d4c70ae461e49aa6c74adc96605abbf5b444eae0ba
6
+ metadata.gz: 98a82b579c6e9cd7dd67d078eff97b0a107fd9375a5eb849178d9d78e06646a776f92995606fdc63920f4e49482a57fc8c101e72df667770939f3a964ef0152f
7
+ data.tar.gz: 5b81ac852c3a60f27985083125a26a375ee5d76c5b26c56c4cfa1d9284bb8449664822bb24ab575d56dc8851dc740034b8f6e95535884176709c9dd15099df4b
@@ -4,6 +4,7 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module PostGIS
6
6
  module ColumnMethods
7
+
7
8
  def spatial(name, options = {})
8
9
  raise "You must set a type. For example: 't.spatial type: :st_point'" unless options[:type]
9
10
  column(name, options[:type], **options)
@@ -44,6 +45,11 @@ module ActiveRecord
44
45
  def st_polygon(name, options = {})
45
46
  column(name, :st_polygon, **options)
46
47
  end
48
+
49
+ private
50
+ def valid_column_definition_options
51
+ super + [:srid, :has_z, :has_m, :geographic, :spatial_type]
52
+ end
47
53
  end
48
54
  end
49
55
 
@@ -25,7 +25,10 @@ module ActiveRecord
25
25
  # has_z: false
26
26
  # has_m: false
27
27
  def self.parse_sql_type(sql_type)
28
- geo_type, srid, has_z, has_m = nil, 0, false, false
28
+ geo_type = nil
29
+ srid = 0
30
+ has_z = false
31
+ has_m = false
29
32
 
30
33
  if sql_type =~ /(geography|geometry)\((.*)\)$/i
31
34
  # geometry(Point)
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  # override
8
8
  # https://github.com/rails/rails/blob/7-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L662
9
9
  # Create a SpatialColumn instead of a PostgreSQL::Column
10
- def new_column_from_field(table_name, field)
11
- column_name, type, default, notnull, oid, fmod, collation, comment, attgenerated = field
10
+ def new_column_from_field(table_name, field, _definitions)
11
+ column_name, type, default, notnull, oid, fmod, collation, comment, identity, attgenerated = field
12
12
  type_metadata = fetch_type_metadata(column_name, type, oid.to_i, fmod.to_i)
13
13
  default_value = extract_value_from_default(default)
14
14
 
@@ -18,7 +18,7 @@ module ActiveRecord
18
18
  default_function = extract_default_function(default_value, default)
19
19
  end
20
20
 
21
- if match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/)
21
+ if (match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/))
22
22
  serial = sequence_name_from_parts(table_name, column_name, match[:suffix]) == match[:sequence_name]
23
23
  end
24
24
 
@@ -35,6 +35,7 @@ module ActiveRecord
35
35
  comment: comment.presence,
36
36
  serial: serial,
37
37
  generated: attgenerated,
38
+ identity: identity.presence,
38
39
  spatial: spatial
39
40
  )
40
41
  end
@@ -9,7 +9,7 @@ module ActiveRecord # :nodoc:
9
9
  # "Geography(Point,4326)"
10
10
  def initialize(name, default, sql_type_metadata = nil, null = true,
11
11
  default_function = nil, collation: nil, comment: nil,
12
- serial: nil, generated: nil, spatial: nil)
12
+ serial: nil, generated: nil, spatial: nil, identity: nil)
13
13
  @sql_type_metadata = sql_type_metadata
14
14
  @geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
15
15
  if spatial
@@ -31,7 +31,7 @@ module ActiveRecord # :nodoc:
31
31
  build_from_sql_type(sql_type_metadata.sql_type)
32
32
  end
33
33
  super(name, default, sql_type_metadata, null, default_function,
34
- collation: collation, comment: comment, serial: serial, generated: generated)
34
+ collation: collation, comment: comment, serial: serial, generated: generated, identity: identity)
35
35
  if spatial? && @srid
36
36
  @limit = { srid: @srid, type: to_type_name(geometric_type) }
37
37
  @limit[:has_z] = true if @has_z
@@ -43,11 +43,11 @@ module ActiveRecord # :nodoc:
43
43
  end
44
44
 
45
45
  def limit_from_options(type, options = {})
46
- spatial_type = geo_type(type)
47
- spatial_type << "Z" if options[:has_z]
48
- spatial_type << "M" if options[:has_m]
49
- spatial_type << ",#{options[:srid] || default_srid(options)}"
50
- spatial_type
46
+ has_z = options[:has_z] ? 'Z' : ''
47
+ has_m = options[:has_m] ? 'M' : ''
48
+ srid = options[:srid] || default_srid(options)
49
+ field_type = [geo_type(type), has_z, has_m].compact.join
50
+ "#{field_type},#{srid}"
51
51
  end
52
52
 
53
53
  def default_srid(options)
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module PostGIS
6
- VERSION = "8.0.3"
6
+ VERSION = "9.0.1"
7
7
  end
8
8
  end
9
9
  end
@@ -9,18 +9,18 @@ require "rgeo/active_record"
9
9
 
10
10
  require "active_record/connection_adapters"
11
11
  require "active_record/connection_adapters/postgresql_adapter"
12
- require "active_record/connection_adapters/postgis/version"
13
- require "active_record/connection_adapters/postgis/column_methods"
14
- require "active_record/connection_adapters/postgis/schema_statements"
15
- require "active_record/connection_adapters/postgis/database_statements"
16
- require "active_record/connection_adapters/postgis/spatial_column_info"
17
- require "active_record/connection_adapters/postgis/spatial_table_definition"
18
- require "active_record/connection_adapters/postgis/spatial_column"
19
- require "active_record/connection_adapters/postgis/arel_tosql"
20
- require "active_record/connection_adapters/postgis/oid/spatial"
21
- require "active_record/connection_adapters/postgis/oid/date_time"
22
- require "active_record/connection_adapters/postgis/type" # has to be after oid/*
23
- require "active_record/connection_adapters/postgis/create_connection"
12
+ require_relative "postgis/version"
13
+ require_relative "postgis/column_methods"
14
+ require_relative "postgis/schema_statements"
15
+ require_relative "postgis/database_statements"
16
+ require_relative "postgis/spatial_column_info"
17
+ require_relative "postgis/spatial_table_definition"
18
+ require_relative "postgis/spatial_column"
19
+ require_relative "postgis/arel_tosql"
20
+ require_relative "postgis/oid/spatial"
21
+ require_relative "postgis/oid/date_time"
22
+ require_relative "postgis/type" # has to be after oid/*
23
+ require_relative "postgis/create_connection"
24
24
  # :startdoc:
25
25
 
26
26
  module ActiveRecord
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_record/connection_adapters/postgis_adapter"
3
+ require_relative "active_record/connection_adapters/postgis_adapter"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgis-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.3
4
+ version: 9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-05 00:00:00.000000000 Z
12
+ date: 2023-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 7.0.0
20
+ version: 7.1.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 7.0.0
27
+ version: 7.1.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rgeo-activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 2.9.1
90
+ version: '2.12'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 2.9.1
97
+ version: '2.12'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rubocop
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: 2.7.0
151
+ version: 3.0.0
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - ">="