Skip to content

Commit

Permalink
Merge pull request #417 from pareeohnos/feature/support-postgis-adapter
Browse files Browse the repository at this point in the history
Add support for postgis adapter
  • Loading branch information
n-rodriguez authored Jun 24, 2023
2 parents 714a6c7 + 518b016 commit b27e0d5
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 2 deletions.
9 changes: 9 additions & 0 deletions appraisal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
ruby-oci8:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
activerecord-postgis-adapter:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "postgis" }'

6.1.7:
sqlite3:
Expand All @@ -26,6 +29,9 @@
ruby-oci8:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
activerecord-postgis-adapter:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "postgis" }'

7.0.4:
sqlite3:
Expand All @@ -40,3 +46,6 @@
ruby-oci8:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
activerecord-postgis-adapter:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "postgis" }'
4 changes: 4 additions & 0 deletions gemfiles/rails_6.0.6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
gem "ruby-oci8"
end

install_if -> { ENV["DB_ADAPTER"] == "postgis" } do
gem "activerecord-postgis-adapter"
end

gemspec path: "../"
4 changes: 4 additions & 0 deletions gemfiles/rails_6.1.7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
gem "ruby-oci8"
end

install_if -> { ENV["DB_ADAPTER"] == "postgis" } do
gem "activerecord-postgis-adapter"
end

gemspec path: "../"
4 changes: 4 additions & 0 deletions gemfiles/rails_7.0.4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
gem "ruby-oci8"
end

install_if -> { ENV["DB_ADAPTER"] == "postgis" } do
gem "activerecord-postgis-adapter"
end

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/ajax-datatables-rails/datatable/simple_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def nulls_last_sql
return unless sort_nulls_last?

case @adapter
when :pg, :postgresql, :postgres, :oracle
when :pg, :postgresql, :postgres, :oracle, :postgis
'NULLS LAST'
when :mysql, :mysql2, :sqlite, :sqlite3
'IS NULL'
Expand Down
5 changes: 5 additions & 0 deletions spec/ajax-datatables-rails/datatable/column_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@
expect(column.send(:type_cast)).to eq('VARCHAR')
end

it 'returns VARCHAR if :db_adapter is :postgis' do
expect(datatable).to receive(:db_adapter) { :postgis }
expect(column.send(:type_cast)).to eq('VARCHAR')
end

it 'returns VARCHAR2(4000) if :db_adapter is :oracle' do
expect(datatable).to receive(:db_adapter) { :oracle }
expect(column.send(:type_cast)).to eq('VARCHAR2(4000)')
Expand Down
8 changes: 8 additions & 0 deletions spec/ajax-datatables-rails/datatable/simple_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
end
end

context 'with postgis database adapter' do
before { parent.db_adapter = :postgis }

it 'sql query' do
expect(nulls_last_order.query('email')).to eq('email DESC NULLS LAST')
end
end

context 'with sqlite database adapter' do
before { parent.db_adapter = :sqlite }

Expand Down
2 changes: 1 addition & 1 deletion spec/support/helpers/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def sample_params_json

def nulls_last_sql(datatable)
case datatable.db_adapter
when :pg, :postgresql, :postgres, :oracle
when :pg, :postgresql, :postgres, :oracle, :postgis
'NULLS LAST'
when :mysql, :mysql2, :sqlite, :sqlite3
'IS NULL'
Expand Down

0 comments on commit b27e0d5

Please sign in to comment.