-
Notifications
You must be signed in to change notification settings - Fork 1
Update for rails 8.1 support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rails-8-support
Are you sure you want to change the base?
Changes from 1 commit
db34114
bd0cb98
bc2ddf7
5c02322
b201a4f
fe2c290
c37b2d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| appraise "ar80" do | ||
| gem "activerecord", "~> 8.0.0" | ||
| end | ||
|
|
||
| appraise "ar81" do | ||
| gem "activerecord", "~> 8.1.0" | ||
| gem "rgeo-activerecord", "~> 8.1.0" | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # This file was generated by Appraisal | ||
|
|
||
| source "https://rubygems.org" | ||
|
|
||
| gem "mysql2", "~> 0.5.2", platform: :ruby | ||
| gem "jdbc-mysql", platform: :jruby | ||
| gem "activerecord-jdbc-adapter", "~> 5.0", platform: :jruby | ||
| gem "ffi-geos", platform: :jruby | ||
| gem "activerecord", "~> 8.1.0" | ||
| gem "rgeo-activerecord", "~> 8.1.0" | ||
|
|
||
| gemspec path: "../" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| module ActiveRecord | ||
| module ConnectionAdapters | ||
| module Mysql2Rgeo | ||
| VERSION = "8.0.0" | ||
| VERSION = "8.1.0" | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,14 +39,11 @@ def self.parse_sql_type(sql_type) | |
| [geo_type, srid] | ||
| end | ||
|
|
||
| def spatial_factory | ||
| @spatial_factories ||= {} | ||
|
|
||
| @spatial_factories[@srid] ||= | ||
| RGeo::ActiveRecord::SpatialFactoryStore.instance.factory( | ||
| geo_type: @geo_type, | ||
| sql_type: @sql_type, | ||
| srid: @srid | ||
| def spatial_factory(srid = @srid) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ActiveRecord 8.1 adds memoization for the various types so we can't use an instance variable anymore. |
||
| RGeo::ActiveRecord::SpatialFactoryStore.instance.factory( | ||
| geo_type: @geo_type, | ||
| sql_type: @sql_type, | ||
| srid: srid | ||
| ) | ||
| end | ||
|
|
||
|
|
@@ -87,15 +84,15 @@ def cast_value(value) | |
| def parse_wkt(string) | ||
| marker = string[4, 1] | ||
| if ["\x00", "\x01"].include?(marker) | ||
| @srid = string[0, 4].unpack1(marker == "\x01" ? "V" : "N") | ||
| RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: @srid).parse(string[4..-1]) | ||
| srid = string[0, 4].unpack1(marker == "\x01" ? "V" : "N") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to added memoization of types in AR 8.1 we have to stop using an instance variable. |
||
| RGeo::WKRep::WKBParser.new(spatial_factory(srid), support_ewkb: true, default_srid: srid).parse(string[4..-1]) | ||
| elsif string[0, 10] =~ /[0-9a-fA-F]{8}0[01]/ | ||
| @srid = string[0, 8].to_i(16) | ||
| @srid = [@srid].pack("V").unpack("N").first if string[9, 1] == "1" | ||
| RGeo::WKRep::WKBParser.new(spatial_factory, support_ewkb: true, default_srid: srid).parse(string[8..-1]) | ||
| srid = string[0, 8].to_i(16) | ||
| srid = [srid].pack("V").unpack("N").first if string[9, 1] == "1" | ||
| RGeo::WKRep::WKBParser.new(spatial_factory(srid), support_ewkb: true, default_srid: srid).parse(string[8..-1]) | ||
| else | ||
| string, @srid = Arel::Visitors::Mysql2Rgeo.parse_node(string) | ||
| RGeo::WKRep::WKTParser.new(spatial_factory, support_ewkt: true, default_srid: @srid).parse(string) | ||
| string, srid = Arel::Visitors::Mysql2Rgeo.parse_node(string) | ||
| RGeo::WKRep::WKTParser.new(spatial_factory(srid), support_ewkt: true, default_srid: srid).parse(string) | ||
| end | ||
| rescue RGeo::Error::ParseError, RGeo::Error::InvalidGeometry | ||
| nil | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API change in ActiveRecord 8.1