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

Add support for postgis adapter #417

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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