Skip to content

Commit

Permalink
Merge pull request #405 from rgeo/bump-7-2
Browse files Browse the repository at this point in the history
Bump to 7.2.0
  • Loading branch information
keithdoggett authored Nov 4, 2024
2 parents 0a678df + ecf8ef3 commit 1290093
Show file tree
Hide file tree
Showing 46 changed files with 348 additions and 278 deletions.
38 changes: 32 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,25 @@ on:
branches:
- master
pull_request:
types: [opened, reopened, synchronize]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# This allows a subsequently queued workflow run to interrupt previous runs.
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: true

jobs:
test-ubuntu-ruby:
# Since the name of the matrix job depends on the version, we define another job with a more stable name.
test_results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Test Results
needs: [test]
steps:
- run: '[[ "${{ needs.test.result }}" == "success" ]]'
test:
runs-on: ubuntu-latest
services:
postgis:
Expand All @@ -27,7 +43,9 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-head, '3.3', '3.2', '3.1']
# https://ruby-lang.org/en/downloads/branches
ruby: ["3.3", "3.2", "3.1"]
# https://www.postgresql.org/support/versioning/
pg: [12-master, 13-master, 14-master, 15-master, 16-master]
steps:
- name: Set Up Actions
Expand All @@ -39,12 +57,20 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Create Database
run: psql -d postgresql://postgres:postgres@localhost:5432/postgres -c "create database postgis_adapter_test"
- name: Create PostGIS Extension
run: psql -d postgresql://postgres:postgres@localhost:5432/postgis_adapter_test -c "create extension postgis"
- name: Setup Database
run: |
psql -d postgresql://postgres:postgres@localhost:5432/postgres \
-c "create database postgis_adapter_test" \
-c "create database activerecord_unittest" \
-c "create database activerecord_unittest2"
for db in postgis_adapter_test activerecord_unittest activerecord_unittest2; do
psql -d postgresql://postgres:postgres@localhost:5432/$db -c "create extension postgis"
done
- name: Run Tests
run: bundle exec rake test
env:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
TESTOPTS: --profile=3
TEST_TIMEOUT: 30
6 changes: 5 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### 9.0.2 / 2024-04-39
### 10.0.0 / 2024-11-04

* ActiveRecord 7.2 support #405

### 9.0.2 / 2024-04-30

* Add `ConnectionHandling` module (copiousfreetime) #390

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ Gemfile:
gem 'activerecord-postgis-adapter'
```

#### Version 10.x supports ActiveRecord 7.2

```
ActiveRecord 7.2
Ruby 3.1.0+
PostGIS 2.0+
```

#### Version 9.x supports ActiveRecord 7.1

```
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "rake/testtask"
require_relative "test/rake_helper"

task default: [:test]
task test: "test:postgis"
task test: "test:all"

Rake::TestTask.new(:test_postgis) do |t|
t.libs << postgis_test_load_paths
Expand Down
10 changes: 6 additions & 4 deletions activerecord-postgis-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@ Gem::Specification.new do |spec|

spec.version = ActiveRecord::ConnectionAdapters::PostGIS::VERSION
spec.authors = ["Daniel Azuma", "Tee Parham"]
spec.email = ["dazuma@gmail.com", "parhameter@gmail.com", "kfdoggett@gmail.com"]
spec.email = ["kfdoggett@gmail.com", "buonomo.ulysse@gmail.com", "terminale@gmail.com"]
spec.homepage = "http://github.com/rgeo/activerecord-postgis-adapter"
spec.license = "BSD-3-Clause"

spec.files = Dir["lib/**/*", "LICENSE.txt"]
spec.platform = Gem::Platform::RUBY

# ruby-lang.org/en/downloads/branches
spec.required_ruby_version = ">= 3.1.0"

spec.add_dependency "activerecord", "~> 7.2.0.beta2"
spec.add_dependency "rgeo-activerecord", "~> 7.0.0"
spec.add_dependency "activerecord", "~> 7.2.0"
spec.add_dependency "rgeo-activerecord", "~> 8.0.0"

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "minitest", "~> 5.4"
spec.add_development_dependency "mocha", "~> 2.4"
spec.add_development_dependency "minitest-excludes", "~> 2.0"
spec.add_development_dependency "benchmark-ips", "~> 2.12"
spec.add_development_dependency "rubocop", "~> 1.50"

spec.metadata = {
"funding_uri" => "https://opencollective.com/rgeo",
"rubygems_mfa_required" => "true"
}
end
33 changes: 33 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env ruby

$:.unshift(File.expand_path("../lib", __dir__))

# require "bundler/setup"
# Bundler.require :development
#
require "activerecord-postgis-adapter"

db_name = "activerecord_postgis_adapter_console"
system("psql -c 'drop database if exists #{db_name}' postgres",
exception: true)
system("psql -c 'create database #{db_name}' postgres",
exception: true)
system(psql = "psql -c 'create extension postgis' #{db_name} ", exception: true)

ActiveRecord::Base.establish_connection(
adapter: "postgis",
database: db_name
)

class Country < ActiveRecord::Base
end

ActiveRecord::Schema.define do
create_table(:countries) do |t|
t.st_polygon(:area, srid: 4326)
t.string(:name)
end
end

require "irb"
IRB.start(__FILE__)
27 changes: 0 additions & 27 deletions lib/active_record/connection_adapters/postgis/create_connection.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/active_record/connection_adapters/postgis/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module ActiveRecord
module ConnectionAdapters
module PostGIS
VERSION = "9.0.2"
VERSION = "10.0.0"
end
end
end
1 change: 0 additions & 1 deletion lib/active_record/connection_adapters/postgis_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
require_relative "postgis/oid/spatial"
require_relative "postgis/oid/date_time"
require_relative "postgis/type" # has to be after oid/*
require_relative "postgis/create_connection"
# :startdoc:

module ActiveRecord
Expand Down
2 changes: 1 addition & 1 deletion lib/activerecord-postgis-adapter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'active_record'
require "active_record"
require "active_record/connection_adapters"
require "rgeo/active_record"
ActiveRecord::ConnectionAdapters.register("postgis", "ActiveRecord::ConnectionAdapters::PostGISAdapter", "active_record/connection_adapters/postgis_adapter")
7 changes: 3 additions & 4 deletions test/cases/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class InvalidAttribute < ActiveRecord::Base

class AttributesTest < ActiveSupport::TestCase
def setup
reset_spatial_store
create_foo
create_spatial_foo
create_invalid_attributes
Expand Down Expand Up @@ -99,20 +98,20 @@ def test_joined_spatial_attribute
private

def create_foo
Foo.connection.create_table :foos, force: true do |t|
Foo.lease_connection.create_table :foos, force: true do |t|
end
end

def create_spatial_foo
SpatialFoo.connection.create_table :spatial_foos, force: true do |t|
SpatialFoo.lease_connection.create_table :spatial_foos, force: true do |t|
t.references :foo
t.st_point :geo_point, geographic: true, srid: 4326
t.st_point :cart_point, srid: 3509
end
end

def create_invalid_attributes
InvalidAttribute.connection.create_table :invalid_attributes, force: true do |t|
InvalidAttribute.lease_connection.create_table :invalid_attributes, force: true do |t|
end
end
end
Expand Down
25 changes: 13 additions & 12 deletions test/cases/basic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module PostGIS
class BasicTest < ActiveSupport::TestCase
def before
def teardown
reset_spatial_store
end

Expand All @@ -13,22 +13,23 @@ def test_version
end

def test_postgis_available
assert_equal "PostGIS", SpatialModel.connection.adapter_name
assert_equal postgis_version, SpatialModel.connection.postgis_lib_version
valid_version = ["2.", "3."].any? { |major_ver| SpatialModel.connection.postgis_lib_version.start_with? major_ver }
assert_equal "PostGIS", SpatialModel.lease_connection.adapter_name
expected_postgis_lib_version_value = SpatialModel.lease_connection.select_value("SELECT postgis_lib_version()")
assert_equal expected_postgis_lib_version_value, SpatialModel.lease_connection.postgis_lib_version
valid_version = ["2.", "3."].any? { |major_ver| SpatialModel.lease_connection.postgis_lib_version.start_with? major_ver }
assert valid_version
end

def test_arel_visitor
visitor = Arel::Visitors::PostGIS.new(SpatialModel.connection)
visitor = Arel::Visitors::PostGIS.new(SpatialModel.lease_connection)
node = RGeo::ActiveRecord::SpatialConstantNode.new("POINT (1.0 2.0)")
collector = Arel::Collectors::PlainString.new
visitor.accept(node, collector)
assert_equal "ST_GeomFromText('POINT (1.0 2.0)')", collector.value
end

def test_arel_visitor_will_not_visit_string
visitor = Arel::Visitors::PostGIS.new(SpatialModel.connection)
visitor = Arel::Visitors::PostGIS.new(SpatialModel.lease_connection)
node = "POINT (1 2)"
collector = Arel::Collectors::PlainString.new

Expand Down Expand Up @@ -111,7 +112,7 @@ def test_default_value

def test_custom_factory
klass = SpatialModel
klass.connection.create_table(:spatial_models, force: true) do |t|
klass.lease_connection.create_table(:spatial_models, force: true) do |t|
t.st_polygon(:area, srid: 4326)
end
klass.reset_column_information
Expand All @@ -127,7 +128,7 @@ def test_custom_factory

def test_spatial_factory_attrs_parsing
klass = SpatialModel
klass.connection.create_table(:spatial_models, force: true) do |t|
klass.lease_connection.create_table(:spatial_models, force: true) do |t|
t.multi_polygon(:areas, srid: 4326)
end
klass.reset_column_information
Expand All @@ -152,14 +153,14 @@ def test_readme_example
spatial_factory_store.register(geo_factory, geo_type: "point", sql_type: "geography")

klass = SpatialModel
klass.connection.create_table(:spatial_models, force: true) do |t|
klass.lease_connection.create_table(:spatial_models, force: true) do |t|
t.column(:shape, :geometry)
t.line_string(:path, srid: 3785)
t.st_point(:latlon, geographic: true)
end
klass.reset_column_information
assert_includes klass.columns.map(&:name), "shape"
klass.connection.change_table(:spatial_models) do |t|
klass.lease_connection.change_table(:spatial_models) do |t|
t.index(:latlon, using: :gist)
end

Expand Down Expand Up @@ -192,7 +193,7 @@ def test_custom_column
end

def test_multi_polygon_column
SpatialModel.connection.create_table(:spatial_models, force: true) do |t|
SpatialModel.lease_connection.create_table(:spatial_models, force: true) do |t|
t.column "m_poly", :multi_polygon
end
SpatialModel.reset_column_information
Expand All @@ -212,7 +213,7 @@ def test_multi_polygon_column
private

def create_model
SpatialModel.connection.create_table(:spatial_models, force: true) do |t|
SpatialModel.lease_connection.create_table(:spatial_models, force: true) do |t|
t.column "latlon", :st_point, srid: 3785
t.column "latlon_geo", :st_point, srid: 4326, geographic: true
t.column "default_latlon", :st_point, srid: 0, default: "POINT(0.0 0.0)"
Expand Down
Loading

0 comments on commit 1290093

Please sign in to comment.