activerecord-trilogis-adapter 8.0.2 → 8.1.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/trilogis/schema_creation.rb +0 -5
- data/lib/active_record/connection_adapters/trilogis/schema_statements.rb +14 -9
- data/lib/active_record/connection_adapters/trilogis/spatial_column.rb +8 -23
- data/lib/active_record/connection_adapters/trilogis/version.rb +1 -1
- data/lib/active_record/type/spatial.rb +11 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c43e31eb6d57d6b2eaf0ed551c13c729e1a7366e71f368871e358f262c6acac
|
|
4
|
+
data.tar.gz: 53488d879dd78083bc5671f5067a9b357a4f453213e2df373c9cf0e321542c6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 384a3d95ec59d189d0615d2571498a0d7c7feff5f65862fd166f14d468eefd73c67fbc89072574b32aafebb1c36a79570f3221a8878f9b0272016a06f784eceb
|
|
7
|
+
data.tar.gz: d87c990d357629fb81929572fb4feedafae6dce63e7eb78be41552bc0d1f22f41a8ccc98c21327ac96060180d49349ad8a78fdb2b52b817d1f97c9243b10076a
|
|
@@ -12,11 +12,6 @@ module ActiveRecord
|
|
|
12
12
|
if options[:srid]
|
|
13
13
|
sql_result = "#{sql} /*!80003 SRID #{options[:srid]} */"
|
|
14
14
|
sql.replace(sql_result)
|
|
15
|
-
|
|
16
|
-
# MySQL does not support DEFAULT values for spatial columns
|
|
17
|
-
# Remove :default option before calling super to prevent SQL errors
|
|
18
|
-
options = options.dup
|
|
19
|
-
options.delete(:default)
|
|
20
15
|
end
|
|
21
16
|
|
|
22
17
|
super
|
|
@@ -87,9 +87,8 @@ module ActiveRecord
|
|
|
87
87
|
# Add NULL constraint
|
|
88
88
|
sql_parts << " NOT NULL" if options[:null] == false
|
|
89
89
|
|
|
90
|
-
#
|
|
91
|
-
|
|
92
|
-
# Users should handle defaults at application level instead
|
|
90
|
+
# Add DEFAULT if specified (allow falsy values like 0/false)
|
|
91
|
+
sql_parts << " DEFAULT #{quote_default_expression(options[:default], nil)}" if options.key?(:default)
|
|
93
92
|
|
|
94
93
|
execute sql_parts.join
|
|
95
94
|
|
|
@@ -162,14 +161,23 @@ module ActiveRecord
|
|
|
162
161
|
# Build a spatial column from field metadata
|
|
163
162
|
def build_spatial_column(table_name, field, field_name, sql_type)
|
|
164
163
|
spatial_info = spatial_column_info(table_name).get(field_name, sql_type)
|
|
164
|
+
|
|
165
|
+
# Keep original sql_type in metadata (point, linestring, etc.)
|
|
166
|
+
# This preserves the actual geometric type for @geo_type_name
|
|
165
167
|
type_metadata = fetch_type_metadata(sql_type)
|
|
166
168
|
|
|
169
|
+
# Lookup cast type as "geometry" for schema dumper compatibility
|
|
170
|
+
# Schema dumper validates cast_type, and only "geometry" is registered as table method
|
|
171
|
+
# Actual type is preserved in sql_type_metadata and limit hash
|
|
172
|
+
cast_type = lookup_cast_type("geometry")
|
|
173
|
+
|
|
167
174
|
SpatialColumn.new(
|
|
168
175
|
field_name,
|
|
169
|
-
|
|
176
|
+
cast_type,
|
|
177
|
+
extract_field_value(field, :Default, :default),
|
|
170
178
|
type_metadata,
|
|
171
179
|
extract_field_value(field, :Null, :null) == "YES",
|
|
172
|
-
|
|
180
|
+
extract_field_value(field, :Extra, :extra),
|
|
173
181
|
collation: extract_field_value(field, :Collation, :collation),
|
|
174
182
|
comment: extract_field_value(field, :Comment, :comment).presence,
|
|
175
183
|
spatial_info: spatial_info
|
|
@@ -189,10 +197,7 @@ module ActiveRecord
|
|
|
189
197
|
column_sql_parts << " SRID #{o.options[:srid]}" if o.options[:srid] && o.options[:srid] != 0
|
|
190
198
|
|
|
191
199
|
column_sql_parts << " NOT NULL" unless o.null
|
|
192
|
-
|
|
193
|
-
# MySQL does not support DEFAULT values for spatial/geometry columns
|
|
194
|
-
# Silently ignore default to prevent SQL syntax errors
|
|
195
|
-
|
|
200
|
+
column_sql_parts << " DEFAULT #{quote_default_expression(o.default, o)}" unless o.default.nil?
|
|
196
201
|
column_sql_parts.join
|
|
197
202
|
else
|
|
198
203
|
super
|
|
@@ -27,11 +27,13 @@ module ActiveRecord
|
|
|
27
27
|
"geometrycollection" => RGeo::Feature::GeometryCollection
|
|
28
28
|
}.freeze
|
|
29
29
|
|
|
30
|
-
def initialize(name, default, sql_type_metadata = nil, null = true,
|
|
30
|
+
def initialize(name, cast_type, default, sql_type_metadata = nil, null = true,
|
|
31
31
|
default_function = nil, collation: nil, comment: nil, spatial_info: nil, **)
|
|
32
|
-
super(name, default, sql_type_metadata, null, default_function,
|
|
32
|
+
super(name, cast_type, default, sql_type_metadata, null, default_function,
|
|
33
|
+
collation: collation, comment: comment)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
# Guard against nil cast_type during OID registration
|
|
36
|
+
return unless cast_type && spatial?
|
|
35
37
|
|
|
36
38
|
if spatial_info
|
|
37
39
|
# Use spatial info from INFORMATION_SCHEMA if available
|
|
@@ -52,6 +54,9 @@ module ActiveRecord
|
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
def spatial?
|
|
57
|
+
# Guard against nil sql_type_metadata during type registration
|
|
58
|
+
return false unless sql_type_metadata&.sql_type
|
|
59
|
+
|
|
55
60
|
TrilogisAdapter::SPATIAL_COLUMN_TYPES.include?(sql_type_metadata.sql_type.downcase)
|
|
56
61
|
end
|
|
57
62
|
|
|
@@ -83,26 +88,6 @@ module ActiveRecord
|
|
|
83
88
|
# Type information is in the type() method
|
|
84
89
|
{ srid: @srid }.compact
|
|
85
90
|
end
|
|
86
|
-
|
|
87
|
-
# Override default to always return nil for spatial columns
|
|
88
|
-
# MySQL does not support DEFAULT values for spatial/geometry columns
|
|
89
|
-
def default
|
|
90
|
-
return super unless spatial?
|
|
91
|
-
|
|
92
|
-
# Always return nil for spatial columns to prevent schema dumper
|
|
93
|
-
# from generating invalid DEFAULT clauses
|
|
94
|
-
nil
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# Override default_function to always return nil for spatial columns
|
|
98
|
-
# MySQL does not support DEFAULT values for spatial/geometry columns
|
|
99
|
-
def default_function
|
|
100
|
-
return super unless spatial?
|
|
101
|
-
|
|
102
|
-
# Always return nil for spatial columns to prevent schema dumper
|
|
103
|
-
# from generating invalid DEFAULT clauses
|
|
104
|
-
nil
|
|
105
|
-
end
|
|
106
91
|
end
|
|
107
92
|
end
|
|
108
93
|
end
|
|
@@ -244,8 +244,18 @@ module ActiveRecord
|
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
def spatial_factory
|
|
247
|
-
|
|
247
|
+
# Rails 8.1 freezes type objects for Ractor compatibility
|
|
248
|
+
# If frozen, create factory without caching to avoid FrozenError
|
|
249
|
+
if frozen?
|
|
250
|
+
return RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
|
|
251
|
+
geo_type: @geo_type,
|
|
252
|
+
sql_type: @sql_type,
|
|
253
|
+
srid: @srid
|
|
254
|
+
)
|
|
255
|
+
end
|
|
248
256
|
|
|
257
|
+
# For non-frozen objects, use instance variable caching
|
|
258
|
+
@spatial_factories ||= {}
|
|
249
259
|
@spatial_factories[@srid] ||= RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
|
|
250
260
|
geo_type: @geo_type,
|
|
251
261
|
sql_type: @sql_type,
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-trilogis-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.0
|
|
4
|
+
version: 8.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ether Moon
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '8.
|
|
18
|
+
version: '8.1'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '8.
|
|
25
|
+
version: '8.1'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rgeo
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -43,14 +43,14 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '8.
|
|
46
|
+
version: '8.1'
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '8.
|
|
53
|
+
version: '8.1'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: minitest
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -179,7 +179,7 @@ dependencies:
|
|
|
179
179
|
version: '2.9'
|
|
180
180
|
description: ActiveRecord connection adapter for MySQL. It extends the Rails built-in
|
|
181
181
|
Trilogy adapter and adds spatial extensions support via RGeo. Compatible with Rails
|
|
182
|
-
8.
|
|
182
|
+
8.1+ native Trilogy adapter. Requires Ruby 3.2+ and Rails 8.1+.
|
|
183
183
|
email: chipseru@gmail.com
|
|
184
184
|
executables: []
|
|
185
185
|
extensions: []
|