Skip to content

Commit e46ab51

Browse files
authored
Add basic support for trilogy
* [Trilogy](https://github.blog/2022-08-25-introducing-trilogy-a-new-database-adapter-for-ruby-on-rails/) is github's alternative to mysql2 * Basically anywhere there's something for mysql2 just do the same thing for Trilogy * Since the database is the same between the two adapters think this is reasonable
1 parent 1b4b478 commit e46ab51

5 files changed

Lines changed: 6 additions & 5 deletions

File tree

database_cleaner-active_record.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
2828
spec.add_development_dependency "mysql2"
2929
spec.add_development_dependency "pg"
3030
spec.add_development_dependency "sqlite3"
31+
spec.add_development_dependency "trilogy"
3132
end

lib/database_cleaner/active_record/deletion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def build_table_stats_query(connection)
6464
end
6565

6666
def information_schema_exists? connection
67-
connection.adapter_name == "Mysql2"
67+
["Mysql2", "Trilogy"].include?(connection.adapter_name)
6868
end
6969
end
7070
end

lib/database_cleaner/active_record/truncation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ConnectionWrapper < SimpleDelegator
6262
def initialize(connection)
6363
extend AbstractAdapter
6464
case connection.adapter_name
65-
when "Mysql2"
65+
when "Mysql2", "Trilogy"
6666
extend AbstractMysqlAdapter
6767
when "SQLite"
6868
extend AbstractMysqlAdapter

spec/database_cleaner/active_record/deletion_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
subject(:strategy) { described_class.new(cache_tables: true) }
9292

9393
it 'caches the list of tables to be deleted from' do
94-
if helper.db == :mysql2
94+
if [:mysql2, :trilogy].include?(helper.db)
9595
expect(strategy).to receive(:build_table_stats_query).once.and_return("")
9696
elsif helper.db == :postgres
9797
expect(strategy.send(:connection)).to receive(:tables_with_schema).once.and_return([])
@@ -108,7 +108,7 @@
108108
subject(:strategy) { described_class.new(cache_tables: false) }
109109

110110
it 'does not cache the list of tables to be deleted from' do
111-
if helper.db == :mysql2
111+
if [:mysql2, :trilogy].include?(helper.db)
112112
expect(strategy).to receive(:build_table_stats_query).twice.and_return("")
113113
elsif helper.db == :postgres
114114
expect(strategy.send(:connection)).to receive(:tables_with_schema).twice.and_return([])

spec/support/database_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class DatabaseHelper < DatabaseCleaner::Spec::DatabaseHelper
55
def self.with_all_dbs &block
6-
%w[mysql2 sqlite3 postgres].map(&:to_sym).each do |db|
6+
%w[mysql2 sqlite3 postgres trilogy].map(&:to_sym).each do |db|
77
yield new(db)
88
end
99
end

0 commit comments

Comments
 (0)