Skip to content

Commit

Permalink
Added support for Trilogy
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Sep 14, 2023
1 parent c26c4d3 commit 7846ca1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 9 additions & 0 deletions gemfiles/trilogy.gemfile
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion lib/active_median/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/median_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/support/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7846ca1

Please sign in to comment.