diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fadc63..d20e71e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,10 @@ jobs: gemfile: gemfiles/mysql2.gemfile adapter: mysql2 mysql: true + - ruby: 3.1 + gemfile: gemfiles/trilogy.gemfile + adapter: trilogy + mysql: true - ruby: 3.1 gemfile: gemfiles/mongoid8.gemfile mongodb: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 61c741a..1674834 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.1 (unreleased) + +- Added support for Trilogy + ## 0.4.0 (2023-05-25) - Fixed error with Active Record 7.0.5 diff --git a/gemfiles/trilogy.gemfile b/gemfiles/trilogy.gemfile new file mode 100644 index 0000000..7fab419 --- /dev/null +++ b/gemfiles/trilogy.gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "activerecord", "~> 7.0.0" +gem "minitest" +gem "activerecord-trilogy-adapter" +gem "rake" +gem "groupdate", github: "ankane/groupdate" diff --git a/lib/active_median/model.rb b/lib/active_median/model.rb index 6e73308..4fb6389 100644 --- a/lib/active_median/model.rb +++ b/lib/active_median/model.rb @@ -51,7 +51,7 @@ def calculate_percentile(column, percentile, operation) relation = case connection.adapter_name - when /mysql/i + when /mysql/i, /trilogy/i # assume mariadb by default # use send as this method is private in Rails 4.2 mariadb = connection.send(:mariadb?) rescue true diff --git a/test/median_test.rb b/test/median_test.rb index eb8535e..815e2fc 100644 --- a/test/median_test.rb +++ b/test/median_test.rb @@ -150,7 +150,7 @@ def test_groupdate def test_non_numeric # TODO debug mysql - skip if adapter == "mysql2" || mongoid? + skip if adapter == "mysql2" || adapter == "trilogy" || mongoid? User.create!(name: 'A') assert_raises(ActiveRecord::StatementInvalid) do diff --git a/test/support/active_record.rb b/test/support/active_record.rb index f430688..70f9e40 100644 --- a/test/support/active_record.rb +++ b/test/support/active_record.rb @@ -6,6 +6,13 @@ ActiveRecord::Base.establish_connection "sqlserver://SA:YourStrong!Passw0rd@localhost:1433/active_median_test" elsif adapter == "redshift" ActiveRecord::Base.establish_connection ENV["DATABASE_URL"] +elsif adapter == "trilogy" + if ActiveRecord::VERSION::STRING.to_f < 7.1 + require "trilogy_adapter/connection" + ActiveRecord::Base.public_send :extend, TrilogyAdapter::Connection + end + + ActiveRecord::Base.establish_connection adapter: adapter, database: "active_median_test", host: "127.0.0.1" else ActiveRecord::Base.establish_connection adapter: adapter, database: sqlite? ? ":memory:" : "active_median_test" end