activerecord-postgis-adapter 8.0.3 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/postgis/column_methods.rb +6 -0
- data/lib/active_record/connection_adapters/postgis/oid/spatial.rb +4 -1
- data/lib/active_record/connection_adapters/postgis/quoting.rb +18 -0
- data/lib/active_record/connection_adapters/postgis/schema_statements.rb +4 -3
- data/lib/active_record/connection_adapters/postgis/spatial_column.rb +2 -2
- data/lib/active_record/connection_adapters/postgis/spatial_table_definition.rb +5 -5
- data/lib/active_record/connection_adapters/postgis/version.rb +1 -1
- data/lib/active_record/connection_adapters/postgis_adapter.rb +14 -34
- data/lib/activerecord-postgis-adapter.rb +5 -1
- metadata +17 -16
- data/lib/active_record/connection_adapters/postgis/create_connection.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 211dbd4d62d434508e3f25601d469c70c5fcb4ffa5e75b5a1a197577df4b34cf
|
4
|
+
data.tar.gz: bb37b037a9acd972649f8ebdc47b9d041a8623ddf25d04cfa98c50c5f81fa2d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7b2327ef909bf8917b38b829c6e8d6eea280ff552aa2926ec546f932dfd9eb0774ba79298fa8c72b5c43d67c7f1fb321d4006d986067ec9eb3299257eb9c578
|
7
|
+
data.tar.gz: 68df2184e5dc4e8dcc975dfa94e12a7b71ce6677a7d5462799e76c53c1737927e6c68f026eacc6aca54199df2b786b1aa97df2a45dfc68d7de540a879771bf72
|
@@ -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
|
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)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module ConnectionAdapters
|
5
|
+
module PostGIS
|
6
|
+
module Quoting
|
7
|
+
def type_cast(value)
|
8
|
+
case value
|
9
|
+
when RGeo::Feature::Instance
|
10
|
+
value.to_s
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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)
|
@@ -5,25 +5,23 @@
|
|
5
5
|
|
6
6
|
# :stopdoc:
|
7
7
|
|
8
|
-
require "rgeo/active_record"
|
9
|
-
|
10
|
-
require "active_record/connection_adapters"
|
11
8
|
require "active_record/connection_adapters/postgresql_adapter"
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
require_relative "postgis/version"
|
10
|
+
require_relative "postgis/column_methods"
|
11
|
+
require_relative "postgis/schema_statements"
|
12
|
+
require_relative "postgis/database_statements"
|
13
|
+
require_relative "postgis/spatial_column_info"
|
14
|
+
require_relative "postgis/spatial_table_definition"
|
15
|
+
require_relative "postgis/spatial_column"
|
16
|
+
require_relative "postgis/arel_tosql"
|
17
|
+
require_relative "postgis/oid/spatial"
|
18
|
+
require_relative "postgis/oid/date_time"
|
19
|
+
require_relative "postgis/quoting"
|
20
|
+
require_relative "postgis/type" # has to be after oid/*
|
24
21
|
# :startdoc:
|
25
22
|
|
26
23
|
module ActiveRecord
|
24
|
+
|
27
25
|
module ConnectionAdapters
|
28
26
|
class PostGISAdapter < PostgreSQLAdapter
|
29
27
|
ADAPTER_NAME = 'PostGIS'
|
@@ -45,6 +43,7 @@ module ActiveRecord
|
|
45
43
|
# http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
|
46
44
|
DEFAULT_SRID = 0
|
47
45
|
|
46
|
+
include PostGIS::Quoting
|
48
47
|
include PostGIS::SchemaStatements
|
49
48
|
include PostGIS::DatabaseStatements
|
50
49
|
|
@@ -163,23 +162,4 @@ module ActiveRecord
|
|
163
162
|
spatial_ref_sys
|
164
163
|
topology
|
165
164
|
]
|
166
|
-
Tasks::DatabaseTasks.register_task(/postgis/, "ActiveRecord::Tasks::PostgreSQLDatabaseTasks")
|
167
|
-
end
|
168
|
-
|
169
|
-
# if using JRUBY, create ArJdbc::PostGIS module
|
170
|
-
# and prepend it to the PostgreSQL adapter since
|
171
|
-
# it is the default adapter_spec.
|
172
|
-
# see: https://github.com/jruby/activerecord-jdbc-adapter/blob/master/lib/arjdbc/postgresql/adapter.rb#27
|
173
|
-
if RUBY_ENGINE == "jruby"
|
174
|
-
module ArJdbc
|
175
|
-
module PostGIS
|
176
|
-
ADAPTER_NAME = 'PostGIS'
|
177
|
-
|
178
|
-
def adapter_name
|
179
|
-
ADAPTER_NAME
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
ArJdbc::PostgreSQL.prepend(ArJdbc::PostGIS)
|
185
165
|
end
|
@@ -1,3 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_record
|
3
|
+
require "active_record"
|
4
|
+
require "active_record/connection_adapters"
|
5
|
+
require "rgeo/active_record"
|
6
|
+
ActiveRecord::ConnectionAdapters.register("postgis", "ActiveRecord::ConnectionAdapters::PostGISAdapter", "active_record/connection_adapters/postgis_adapter")
|
7
|
+
ActiveRecord::Tasks::DatabaseTasks.register_task(/postgis/, "ActiveRecord::Tasks::PostgreSQLDatabaseTasks")
|
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:
|
4
|
+
version: 11.0.0
|
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:
|
12
|
+
date: 2025-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 8.0.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:
|
27
|
+
version: 8.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rgeo-activerecord
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 8.0.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 8.0.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,33 +68,33 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '5.4'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: minitest-excludes
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '2.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '2.0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: benchmark-ips
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 2.
|
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.
|
97
|
+
version: '2.12'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: rubocop
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,9 +113,9 @@ description: ActiveRecord connection adapter for PostGIS. It is based on the sto
|
|
113
113
|
PostgreSQL adapter, and adds built-in support for the spatial extensions provided
|
114
114
|
by PostGIS. It uses the RGeo library to represent spatial data in Ruby.
|
115
115
|
email:
|
116
|
-
- dazuma@gmail.com
|
117
|
-
- parhameter@gmail.com
|
118
116
|
- kfdoggett@gmail.com
|
117
|
+
- buonomo.ulysse@gmail.com
|
118
|
+
- terminale@gmail.com
|
119
119
|
executables: []
|
120
120
|
extensions: []
|
121
121
|
extra_rdoc_files: []
|
@@ -123,10 +123,10 @@ files:
|
|
123
123
|
- LICENSE.txt
|
124
124
|
- lib/active_record/connection_adapters/postgis/arel_tosql.rb
|
125
125
|
- lib/active_record/connection_adapters/postgis/column_methods.rb
|
126
|
-
- lib/active_record/connection_adapters/postgis/create_connection.rb
|
127
126
|
- lib/active_record/connection_adapters/postgis/database_statements.rb
|
128
127
|
- lib/active_record/connection_adapters/postgis/oid/date_time.rb
|
129
128
|
- lib/active_record/connection_adapters/postgis/oid/spatial.rb
|
129
|
+
- lib/active_record/connection_adapters/postgis/quoting.rb
|
130
130
|
- lib/active_record/connection_adapters/postgis/schema_statements.rb
|
131
131
|
- lib/active_record/connection_adapters/postgis/spatial_column.rb
|
132
132
|
- lib/active_record/connection_adapters/postgis/spatial_column_info.rb
|
@@ -139,6 +139,7 @@ homepage: http://github.com/rgeo/activerecord-postgis-adapter
|
|
139
139
|
licenses:
|
140
140
|
- BSD-3-Clause
|
141
141
|
metadata:
|
142
|
+
funding_uri: https://opencollective.com/rgeo
|
142
143
|
rubygems_mfa_required: 'true'
|
143
144
|
post_install_message:
|
144
145
|
rdoc_options: []
|
@@ -148,14 +149,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
149
|
requirements:
|
149
150
|
- - ">="
|
150
151
|
- !ruby/object:Gem::Version
|
151
|
-
version: 2.
|
152
|
+
version: 3.2.0
|
152
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
154
|
requirements:
|
154
155
|
- - ">="
|
155
156
|
- !ruby/object:Gem::Version
|
156
157
|
version: '0'
|
157
158
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
159
|
+
rubygems_version: 3.5.22
|
159
160
|
signing_key:
|
160
161
|
specification_version: 4
|
161
162
|
summary: ActiveRecord adapter for PostGIS, based on RGeo.
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if RUBY_ENGINE == "jruby"
|
4
|
-
require "active_record/connection_adapters/jdbcpostgresql_adapter"
|
5
|
-
else
|
6
|
-
require "pg"
|
7
|
-
end
|
8
|
-
|
9
|
-
module ActiveRecord # :nodoc:
|
10
|
-
module ConnectionHandling # :nodoc:
|
11
|
-
if RUBY_ENGINE == "jruby"
|
12
|
-
|
13
|
-
# modified from https://github.com/jruby/activerecord-jdbc-adapter/blob/master/lib/arjdbc/postgresql/connection_methods.rb#L3
|
14
|
-
def postgis_connection(config)
|
15
|
-
config = config.deep_dup
|
16
|
-
config = symbolize_keys_if_necessary(config)
|
17
|
-
|
18
|
-
config[:adapter_class] = ConnectionAdapters::PostGISAdapter
|
19
|
-
postgresql_connection(config)
|
20
|
-
end
|
21
|
-
|
22
|
-
alias_method :jdbcpostgis_connection, :postgis_connection
|
23
|
-
|
24
|
-
else
|
25
|
-
|
26
|
-
# Based on the default <tt>postgresql_connection</tt> definition from ActiveRecord.
|
27
|
-
# https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
|
28
|
-
# FULL REPLACEMENT because we need to create a different class.
|
29
|
-
def postgis_connection(config)
|
30
|
-
conn_params = config.symbolize_keys.compact
|
31
|
-
|
32
|
-
# Map ActiveRecords param names to PGs.
|
33
|
-
conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
|
34
|
-
conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
|
35
|
-
|
36
|
-
# Forward only valid config params to PG.connect
|
37
|
-
valid_conn_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]
|
38
|
-
conn_params.slice!(*valid_conn_param_keys)
|
39
|
-
|
40
|
-
ConnectionAdapters::PostGISAdapter.new(
|
41
|
-
ConnectionAdapters::PostGISAdapter.new_client(conn_params),
|
42
|
-
logger,
|
43
|
-
conn_params,
|
44
|
-
config
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|