Skip to content
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
- sqlite3
- postgresql
- mysql2
- trilogy
- oracle_enhanced

steps:
Expand All @@ -85,7 +86,7 @@ jobs:

# See: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#mysql
run: |
if [ "${DB_ADAPTER}" = "mysql2" ]; then
if [ "${DB_ADAPTER}" = "mysql2" ] || [ "${DB_ADAPTER}" = "trilogy" ]; then
sudo systemctl start mysql.service
mysql -u root -proot -e 'create database ajax_datatables_rails;'
fi
Expand Down
12 changes: 12 additions & 0 deletions appraisal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
mysql2:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
activerecord-trilogy-adapter:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "trilogy" }'
activerecord-oracle_enhanced-adapter:
version: ~> 6.0.0
install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
Expand All @@ -23,6 +26,9 @@
mysql2:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
activerecord-trilogy-adapter:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "trilogy" }'
activerecord-oracle_enhanced-adapter:
version: ~> 6.1.0
install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
Expand All @@ -40,6 +46,9 @@
mysql2:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
activerecord-trilogy-adapter:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "trilogy" }'
activerecord-oracle_enhanced-adapter:
version: ~> 7.0.0
install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
Expand All @@ -57,6 +66,9 @@
mysql2:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
activerecord-trilogy-adapter:
version: ''
install_if: '-> { ENV["DB_ADAPTER"] == "trilogy" }'
# activerecord-oracle_enhanced-adapter:
# version: ~> 7.0.0
# install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/rails_6.0.6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ install_if -> { ENV["DB_ADAPTER"] == "mysql2" } do
gem "mysql2"
end

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

install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
gem "activerecord-oracle_enhanced-adapter", "~> 6.0.0"
gem "ruby-oci8"
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/rails_6.1.7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ install_if -> { ENV["DB_ADAPTER"] == "mysql2" } do
gem "mysql2"
end

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

install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
gem "activerecord-oracle_enhanced-adapter", "~> 6.1.0"
gem "ruby-oci8"
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/rails_7.0.8.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ install_if -> { ENV["DB_ADAPTER"] == "mysql2" } do
gem "mysql2"
end

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

install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
gem "activerecord-oracle_enhanced-adapter", "~> 7.0.0"
gem "ruby-oci8"
Expand Down
4 changes: 4 additions & 0 deletions gemfiles/rails_7.1.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ install_if -> { ENV["DB_ADAPTER"] == "mysql2" } do
gem "mysql2"
end

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

install_if -> { ENV["DB_ADAPTER"] == "postgis" } do
gem "activerecord-postgis-adapter"
end
Expand Down
1 change: 1 addition & 0 deletions lib/ajax-datatables-rails/datatable/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def formatted_value
DB_ADAPTER_TYPE_CAST = {
mysql: TYPE_CAST_MYSQL,
mysql2: TYPE_CAST_MYSQL,
trilogy: TYPE_CAST_MYSQL,
sqlite: TYPE_CAST_SQLITE,
sqlite3: TYPE_CAST_SQLITE,
oracle: TYPE_CAST_ORACLE,
Expand Down
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 @@ -47,7 +47,7 @@ def nulls_last_sql
case @adapter
when :pg, :postgresql, :postgres, :oracle, :postgis
'NULLS LAST'
when :mysql, :mysql2, :sqlite, :sqlite3
when :mysql, :mysql2, :trilogy, :sqlite, :sqlite3
'IS NULL'
else
raise "unsupported database adapter: #{@adapter}"
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 @@ -188,6 +188,11 @@
expect(column.send(:type_cast)).to eq('CHAR')
end

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

it 'returns CHAR if :db_adapter is :mysql' do
expect(datatable).to receive(:db_adapter) { :mysql }
expect(column.send(:type_cast)).to eq('CHAR')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@
)
end
end

context 'when db_adapter is trilogy' do
it 'can call #to_sql on returned object' do
result = datatable.build_conditions_for_selected_columns
expect(result).to respond_to(:to_sql)
expect(result.to_sql).to eq(
"CAST(`users`.`username` AS CHAR) LIKE '%doe%' AND CAST(`users`.`email` AS CHAR) LIKE '%example%'"
)
end
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ test:
port: 3306
username: 'root'
password: 'root'
<% elsif adapter == 'trilogy' %>
host: '127.0.0.1'
port: 3306
username: 'root'
password: 'root'
<% elsif adapter == 'oracle_enhanced' %>
host: '127.0.0.1/xe'
username: <%= ENV.fetch('USER') %>
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def self.oracle?
end

def self.mysql?
ENV['DB_ADAPTER'] == 'mysql2'
ENV['DB_ADAPTER'] == 'mysql2' || ENV['DB_ADAPTER'] == 'trilogy'
end

def self.postgresql?
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 @@ -72,7 +72,7 @@ def nulls_last_sql(datatable)
case datatable.db_adapter
when :pg, :postgresql, :postgres, :oracle, :postgis
'NULLS LAST'
when :mysql, :mysql2, :sqlite, :sqlite3
when :mysql, :mysql2, :trilogy, :sqlite, :sqlite3
'IS NULL'
else
raise 'unsupported database adapter'
Expand Down