activerecord-postgis-adapter 8.0.0 → 8.0.2
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/oid/date_time.rb +20 -0
- data/lib/active_record/connection_adapters/postgis/schema_statements.rb +6 -45
- data/lib/active_record/connection_adapters/postgis/spatial_column.rb +2 -2
- data/lib/active_record/connection_adapters/postgis/spatial_table_definition.rb +7 -1
- data/lib/active_record/connection_adapters/postgis/version.rb +1 -1
- data/lib/active_record/connection_adapters/postgis_adapter.rb +19 -0
- metadata +32 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a73b6c9fb325971ec1f593c4698c12b68d8e9fd96e3af64f720d842f47f6c7d0
|
|
4
|
+
data.tar.gz: 52e0aa909ca3a69c74bcab5d6f0af4bd43f6610192a834743c632f803e17ce3c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b1f926834a893d07c9e09928ffbce2635906292a8dbad8f949df978f779c06841cd36b89ab0c160f5f2f197fffeb82907e2b24f18fd2dffd34b8184f9591bdf
|
|
7
|
+
data.tar.gz: 7da434681d9cfa4f120b76768d0bdab74724e3eca2928df1c4897c94ee7e6b1f8b2367c4a2213831b3a8943b3ac4759fc7de2c8583f422640835fcc2563efe68
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module ConnectionAdapters
|
|
5
|
+
module PostGIS
|
|
6
|
+
module OID
|
|
7
|
+
module DateTime
|
|
8
|
+
protected
|
|
9
|
+
|
|
10
|
+
# Uses PostGIS instead of PostgreSQLAdapter
|
|
11
|
+
def real_type_unless_aliased(real_type)
|
|
12
|
+
ActiveRecord::ConnectionAdapters::PostGISAdapter.datetime_type == real_type ? :datetime : real_type
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
PostgreSQL::OID::DateTime.prepend(DateTime)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -5,18 +5,17 @@ module ActiveRecord
|
|
|
5
5
|
module PostGIS
|
|
6
6
|
module SchemaStatements
|
|
7
7
|
# override
|
|
8
|
-
# https://github.com/rails/rails/blob/
|
|
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
10
|
def new_column_from_field(table_name, field)
|
|
11
|
-
column_name, type, default, notnull, oid, fmod, collation, comment = field
|
|
11
|
+
column_name, type, default, notnull, oid, fmod, collation, comment, 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
|
default_function = extract_default_function(default_value, default)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
16
|
+
if match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/)
|
|
17
|
+
serial = sequence_name_from_parts(table_name, column_name, match[:suffix]) == match[:sequence_name]
|
|
18
|
+
end
|
|
20
19
|
|
|
21
20
|
# {:dimension=>2, :has_m=>false, :has_z=>false, :name=>"latlon", :srid=>0, :type=>"GEOMETRY"}
|
|
22
21
|
spatial = spatial_column_info(table_name).get(column_name, type_metadata.sql_type)
|
|
@@ -30,49 +29,11 @@ module ActiveRecord
|
|
|
30
29
|
collation: collation,
|
|
31
30
|
comment: comment.presence,
|
|
32
31
|
serial: serial,
|
|
32
|
+
generated: attgenerated,
|
|
33
33
|
spatial: spatial
|
|
34
34
|
)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# override
|
|
38
|
-
# https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L544
|
|
39
|
-
#
|
|
40
|
-
# returns Postgresql sql type string
|
|
41
|
-
# examples:
|
|
42
|
-
# "geometry(Point,4326)"
|
|
43
|
-
# "geography(Point,4326)"
|
|
44
|
-
#
|
|
45
|
-
# note: type alone is not enough to detect the sql type,
|
|
46
|
-
# so `limit` is used to pass the additional information. :(
|
|
47
|
-
#
|
|
48
|
-
# type_to_sql(:geography, limit: "Point,4326")
|
|
49
|
-
# => "geography(Point,4326)"
|
|
50
|
-
def type_to_sql(type, limit: nil, precision: nil, scale: nil, array: nil, **)
|
|
51
|
-
case type.to_s
|
|
52
|
-
when "geometry", "geography"
|
|
53
|
-
"#{type}(#{limit})"
|
|
54
|
-
else
|
|
55
|
-
super
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# override
|
|
60
|
-
def native_database_types
|
|
61
|
-
# Add spatial types
|
|
62
|
-
super.merge(
|
|
63
|
-
geography: { name: "geography" },
|
|
64
|
-
geometry: { name: "geometry" },
|
|
65
|
-
geometry_collection: { name: "geometry_collection" },
|
|
66
|
-
line_string: { name: "line_string" },
|
|
67
|
-
multi_line_string: { name: "multi_line_string" },
|
|
68
|
-
multi_point: { name: "multi_point" },
|
|
69
|
-
multi_polygon: { name: "multi_polygon" },
|
|
70
|
-
spatial: { name: "geometry" },
|
|
71
|
-
st_point: { name: "st_point" },
|
|
72
|
-
st_polygon: { name: "st_polygon" }
|
|
73
|
-
)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
37
|
# override
|
|
77
38
|
def create_table_definition(*args, **kwargs)
|
|
78
39
|
PostGIS::TableDefinition.new(self, *args, **kwargs)
|
|
@@ -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, spatial: nil)
|
|
12
|
+
serial: nil, generated: nil, spatial: 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)
|
|
34
|
+
collation: collation, comment: comment, serial: serial, generated: generated)
|
|
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
|
|
@@ -8,7 +8,13 @@ module ActiveRecord # :nodoc:
|
|
|
8
8
|
|
|
9
9
|
# super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
|
|
10
10
|
def new_column_definition(name, type, **options)
|
|
11
|
-
|
|
11
|
+
col_type = if type.to_sym == :virtual
|
|
12
|
+
options[:type]
|
|
13
|
+
else
|
|
14
|
+
type
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if (info = PostGISAdapter.spatial_column_options(col_type))
|
|
12
18
|
if (limit = options.delete(:limit)) && limit.is_a?(::Hash)
|
|
13
19
|
options.merge!(limit)
|
|
14
20
|
end
|
|
@@ -18,6 +18,7 @@ require "active_record/connection_adapters/postgis/spatial_table_definition"
|
|
|
18
18
|
require "active_record/connection_adapters/postgis/spatial_column"
|
|
19
19
|
require "active_record/connection_adapters/postgis/arel_tosql"
|
|
20
20
|
require "active_record/connection_adapters/postgis/oid/spatial"
|
|
21
|
+
require "active_record/connection_adapters/postgis/oid/date_time"
|
|
21
22
|
require "active_record/connection_adapters/postgis/type" # has to be after oid/*
|
|
22
23
|
require "active_record/connection_adapters/postgis/create_connection"
|
|
23
24
|
# :startdoc:
|
|
@@ -90,6 +91,24 @@ module ActiveRecord
|
|
|
90
91
|
|
|
91
92
|
super
|
|
92
93
|
end
|
|
94
|
+
|
|
95
|
+
def native_database_types
|
|
96
|
+
@native_database_types ||= begin
|
|
97
|
+
default_types = PostgreSQLAdapter.native_database_types
|
|
98
|
+
default_types.merge({
|
|
99
|
+
geography: { name: "geography" },
|
|
100
|
+
geometry: { name: "geometry" },
|
|
101
|
+
geometry_collection: { name: "geometry_collection" },
|
|
102
|
+
line_string: { name: "line_string" },
|
|
103
|
+
multi_line_string: { name: "multi_line_string" },
|
|
104
|
+
multi_point: { name: "multi_point" },
|
|
105
|
+
multi_polygon: { name: "multi_polygon" },
|
|
106
|
+
spatial: { name: "geometry" },
|
|
107
|
+
st_point: { name: "st_point" },
|
|
108
|
+
st_polygon: { name: "st_polygon" }
|
|
109
|
+
})
|
|
110
|
+
end
|
|
111
|
+
end
|
|
93
112
|
end
|
|
94
113
|
|
|
95
114
|
def srs_database_columns
|
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.
|
|
4
|
+
version: 8.0.2
|
|
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: 2023-05-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activerecord
|
|
@@ -81,6 +81,34 @@ dependencies:
|
|
|
81
81
|
- - "~>"
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
83
|
version: '1.1'
|
|
84
|
+
- !ruby/object:Gem::Dependency
|
|
85
|
+
name: benchmark-ips
|
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - "~>"
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: 2.9.1
|
|
91
|
+
type: :development
|
|
92
|
+
prerelease: false
|
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - "~>"
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: 2.9.1
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: rubocop
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - "~>"
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '1.50'
|
|
105
|
+
type: :development
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - "~>"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '1.50'
|
|
84
112
|
description: ActiveRecord connection adapter for PostGIS. It is based on the stock
|
|
85
113
|
PostgreSQL adapter, and adds built-in support for the spatial extensions provided
|
|
86
114
|
by PostGIS. It uses the RGeo library to represent spatial data in Ruby.
|
|
@@ -97,6 +125,7 @@ files:
|
|
|
97
125
|
- lib/active_record/connection_adapters/postgis/column_methods.rb
|
|
98
126
|
- lib/active_record/connection_adapters/postgis/create_connection.rb
|
|
99
127
|
- lib/active_record/connection_adapters/postgis/database_statements.rb
|
|
128
|
+
- lib/active_record/connection_adapters/postgis/oid/date_time.rb
|
|
100
129
|
- lib/active_record/connection_adapters/postgis/oid/spatial.rb
|
|
101
130
|
- lib/active_record/connection_adapters/postgis/schema_statements.rb
|
|
102
131
|
- lib/active_record/connection_adapters/postgis/spatial_column.rb
|
|
@@ -126,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
126
155
|
- !ruby/object:Gem::Version
|
|
127
156
|
version: '0'
|
|
128
157
|
requirements: []
|
|
129
|
-
rubygems_version: 3.
|
|
158
|
+
rubygems_version: 3.2.33
|
|
130
159
|
signing_key:
|
|
131
160
|
specification_version: 4
|
|
132
161
|
summary: ActiveRecord adapter for PostGIS, based on RGeo.
|