Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ jobs:
--health-timeout 5s
--health-retries 5
env:
AR_VERSION: 8.0.0.1
AR_VERSION: 8.1.0.rc1
strategy:
fail-fast: false
matrix:
# https://ruby-lang.org/en/downloads/branches
ruby: ["3.4", "3.3", "3.2"]
# https://www.postgresql.org/support/versioning/
pg: [12-master, 13-master, 14-master, 15-master, 16-master]
pg: [13-master, 14-master, 15-master, 16-master, 17-master]
Copy link

@modosc modosc Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pg 18 was released a month ago is there a reason not to include it here? my fault, this pr went up before it came out. still might be nice to add here though.

steps:
- name: Set Up Actions
uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ gemspec
gem "pg", "~> 1.0", platform: :ruby
gem "byebug" if ENV["BYEBUG"]

gem "rgeo-activerecord", git: "https://github.com/rgeo/rgeo-activerecord.git"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting!

Do rgeo need any release ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I had a PR for 8.1 support merged a few weeks ago..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it now ! Thank you for the PR


def activerecord_version
return ENV["AR_VERSION"] if ENV["AR_VERSION"]

Expand Down
6 changes: 3 additions & 3 deletions activerecord-postgis-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Gem::Specification.new do |spec|
spec.summary = "ActiveRecord adapter for PostGIS, based on RGeo."
spec.description =
"ActiveRecord connection adapter for PostGIS. It is based on the stock " \
"PostgreSQL adapter, and adds built-in support for the spatial extensions "\
"PostgreSQL adapter, and adds built-in support for the spatial extensions " \
"provided by PostGIS. It uses the RGeo library to represent spatial data in Ruby."

spec.version = ActiveRecord::ConnectionAdapters::PostGIS::VERSION
Expand All @@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
# ruby-lang.org/en/downloads/branches
spec.required_ruby_version = ">= 3.2.0"

spec.add_dependency "activerecord", "~> 8.0.0"
spec.add_dependency "rgeo-activerecord", "~> 8.0.0"
spec.add_dependency "activerecord", "~> 8.1.0.rc1"
spec.add_dependency "rgeo-activerecord"

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "minitest", "~> 5.4"
Expand Down
14 changes: 13 additions & 1 deletion lib/active_record/connection_adapters/postgis/oid/spatial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module OID
# Responsible for parsing sql_types returned from the database and WKT features.
class Spatial < Type::Value
def initialize(geo_type: "geometry", srid: 0, has_z: false, has_m: false, geographic: false)
super()
@geo_type = geo_type
@srid = srid
@has_z = has_z
Expand All @@ -25,6 +26,11 @@ def initialize(geo_type: "geometry", srid: 0, has_z: false, has_m: false, geogra
# has_z: false
# has_m: false
def self.parse_sql_type(sql_type)
# Could be nil during type registration
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure why this happens as I'm not fully familiar with active record internals, but this seems to work.

Copy link
Member

@BuonOmo BuonOmo Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm investigating it these days on crdb adapter, I hope I'll come with more information and a clean solution soonish :) (before the end of this month)

if sql_type.nil?
return [nil, 0, false, false, false]
end

geo_type = nil
srid = 0
has_z = false
Expand Down Expand Up @@ -53,10 +59,16 @@ def self.parse_sql_type(sql_type)
end

def spatial_factory
@spatial_factory ||=
if frozen?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debated on this branch for a bit, not sure when this object would be unfrozen now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should see if there is a performance a space change, but I'd rather bubble that back up to the initialiser than create a factory every time. Also the if frozen? branch is useless since the goal of ractor compatibility for types as I understood is to have them frozen all the time !

RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
factory_attrs
)
else
@spatial_factory ||=
RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
factory_attrs
)
end
end

def spatial?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def new_column_from_field(table_name, field, _definitions)
type_metadata = fetch_type_metadata(column_name, type, oid.to_i, fmod.to_i)
default_value = extract_value_from_default(default)

if attgenerated.present?
default_function = default
else
default_function = extract_default_function(default_value, default)
end
default_function = if attgenerated.present?
default
else
extract_default_function(default_value, default)
end

if (match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/))
serial = sequence_name_from_parts(table_name, column_name, match[:suffix]) == match[:sequence_name]
Expand All @@ -27,6 +27,7 @@ def new_column_from_field(table_name, field, _definitions)

SpatialColumn.new(
column_name,
get_oid_type(oid.to_i, fmod.to_i, column_name, type),
default_value,
type_metadata,
!notnull,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SpatialColumn < ConnectionAdapters::PostgreSQLColumn # :nodoc:
# sql_type examples:
# "Geometry(Point,4326)"
# "Geography(Point,4326)"
def initialize(name, default, sql_type_metadata = nil, null = true,
def initialize(name, cast_type, default, sql_type_metadata = nil, null = true,
default_function = nil, collation: nil, comment: nil,
serial: nil, generated: nil, spatial: nil, identity: nil)
@sql_type_metadata = sql_type_metadata
Expand All @@ -30,7 +30,7 @@ def initialize(name, default, sql_type_metadata = nil, null = true,
# @geometric_type = geo_type_from_sql_type(sql_type)
build_from_sql_type(sql_type_metadata.sql_type)
end
super(name, default, sql_type_metadata, null, default_function,
super(name, cast_type, default, sql_type_metadata, null, default_function,
collation: collation, comment: comment, serial: serial, generated: generated, identity: identity)
if spatial? && @srid
@limit = { srid: @srid, type: to_type_name(geometric_type) }
Expand Down
Loading