Skip to content
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

feat!: ActiveRecord 7.2 support #397

Merged
merged 4 commits into from
Jul 5, 2024
Merged

feat!: ActiveRecord 7.2 support #397

merged 4 commits into from
Jul 5, 2024

Conversation

seuros
Copy link
Contributor

@seuros seuros commented Jun 18, 2024

Here is a working implementation for Rails 7.2

ping @theonlyriddle @anthony0030 @ugisozols @keithdoggett

JRuby code was removed until it start supporting Rails 7.1 and 7.2

closes #395

@seuros seuros force-pushed the master branch 2 times, most recently from 4cb4959 to b1485ec Compare June 18, 2024 15:16
@seuros seuros marked this pull request as ready for review June 19, 2024 20:07
@seuros
Copy link
Contributor Author

seuros commented Jun 19, 2024

@keithdoggett : The errors are flacky and happen when the adapter is not connected yet in CI.
rerunning the test will make them pass.

lib/activerecord-postgis-adapter.rb Show resolved Hide resolved
test/cases/basic_test.rb Show resolved Hide resolved
@@ -5,22 +5,25 @@
module PostGIS
class SchemaStatementsTest < ActiveSupport::TestCase
def test_initialize_type_map
initialized_types = SpatialModel.connection.send(:type_map).keys
SpatialModel.with_connection do |connection|
assert connection.connected?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is flacky.

Copy link
Member

Choose a reason for hiding this comment

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

Probably due to how the adapter is registered now?

Copy link
Contributor Author

@seuros seuros Jun 20, 2024

Choose a reason for hiding this comment

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

No, it just flacky in CI.

I will focus on the cause later.

If you rerun the failed builds, they will become green.

Copy link
Member

Choose a reason for hiding this comment

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

Was it flaky before this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in CI.

.github/workflows/tests.yml Outdated Show resolved Hide resolved
@keithdoggett
Copy link
Member

@seuros thank you for submitting this I'll review this in the morning. Thanks for all the help.

@anthony0030
Copy link

@seuros thank you for your continued effort. I and @theonlyriddle will be unable to work on the project that we need this for, for some time.

We appreciate your effort very much!

Copy link
Member

@keithdoggett keithdoggett left a comment

Choose a reason for hiding this comment

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

@seuros looks good. Just a few questions here. Thanks again

Gemfile Outdated Show resolved Hide resolved
test/cases/basic_test.rb Show resolved Hide resolved
@@ -5,22 +5,25 @@
module PostGIS
class SchemaStatementsTest < ActiveSupport::TestCase
def test_initialize_type_map
initialized_types = SpatialModel.connection.send(:type_map).keys
SpatialModel.with_connection do |connection|
assert connection.connected?
Copy link
Member

Choose a reason for hiding this comment

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

Probably due to how the adapter is registered now?

test/rake_helper.rb Show resolved Hide resolved
Copy link
Member

@BuonOmo BuonOmo left a comment

Choose a reason for hiding this comment

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

A few reviews, to me the Gemfile part is important. I also have doubts about removing the JRUBY code, is it really bothering us? My opinion is that support will come at some point and that we will just have to write the same code again...

Besides that I think we're pretty good. Thank you for the dedication !

.github/workflows/tests.yml Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
@@ -5,22 +5,25 @@
module PostGIS
class SchemaStatementsTest < ActiveSupport::TestCase
def test_initialize_type_map
initialized_types = SpatialModel.connection.send(:type_map).keys
SpatialModel.with_connection do |connection|
assert connection.connected?
Copy link
Member

Choose a reason for hiding this comment

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

Was it flaky before this PR?

@BuonOmo
Copy link
Member

BuonOmo commented Jun 23, 2024

I think there is still some misunderstanding in the Gemfile part, to me it is important that we test on the latest AR patch.

@seuros
Copy link
Contributor Author

seuros commented Jul 1, 2024

@BuonOmo , I get it.
I want to lock it to ˜> 7.2.0 when we release it .

@BuonOmo
Copy link
Member

BuonOmo commented Jul 1, 2024

So the script you removed allowed to verify that we were properly testing against the latest patch. What you are doing isn't, unless I missed something which you could explain to me ?

@seuros
Copy link
Contributor Author

seuros commented Jul 1, 2024

No the script that i removed, pull in each run the list from rubygems , select the last one and use it as a tag.

You can bypass the network calls by setting AR_VERSION

@BuonOmo
Copy link
Member

BuonOmo commented Jul 2, 2024

No the script that i removed, pull in each run the list from rubygems , select the last one and use it as a tag.

Which means it forces usage of the very last patch, which is what want IMHO!

@seuros
Copy link
Contributor Author

seuros commented Jul 2, 2024

fair! I restored the file.

@theonlyriddle
Copy link

@seuros I updated my gem to use your current master branch to see how things are running. When I started my application, it crashed at my initializer file config/initializers/rgeo.rb with the error uninitialized constant RGeo::ActiveRecord (NameError).

The contents of the initializer file are below.

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  # By default, use the GEOS implementation for spatial columns.
  # config.default = RGeo::Geos.factory_generator

  # # But use a geographic implementation for point columns.
  # config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end

class RGeo::GeoJSON::Feature
  def properties
    @properties
  end
end

I only have this problem on your branch. Just thought to bring this to your attention.

@seuros
Copy link
Contributor Author

seuros commented Jul 2, 2024

@theonlyriddle

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  # By default, use the GEOS implementation for spatial columns.
  # config.default = RGeo::Geos.factory_generator

  # # But use a geographic implementation for point columns.
  # config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end

Is doing nothing in your case.

@theonlyriddle
Copy link

@seuros I agree with you, the code I posted does nothing as it's commented out.

However, this code from the documentation (essentially the same as what I posted) results in the same error that I described above.

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  # By default, use the GEOS implementation for spatial columns.
  config.default = RGeo::Geos.factory_generator

  # But use a geographic implementation for point columns.
  config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end

Gemfile Outdated Show resolved Hide resolved
@seuros
Copy link
Contributor Author

seuros commented Jul 4, 2024

@theonlyriddle, Right!
we need to upgrade the documentation to configure it after initialization.
Now the adapters are lazy loaded and available only after first usage.

Copy link
Member

@BuonOmo BuonOmo left a comment

Choose a reason for hiding this comment

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

LGTM, I think once @theonlyriddle's issue is sorted out we should be good to go!

@seuros
Copy link
Contributor Author

seuros commented Jul 4, 2024

@BuonOmo :shipit:

@BuonOmo BuonOmo merged commit 9ed6cb5 into rgeo:master Jul 5, 2024
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inquiry on Rails 7.2 Support Effort
5 participants