Skip to content

Commit

Permalink
Merge pull request #85 from zhaitz/main
Browse files Browse the repository at this point in the history
Add basic support for trilogy
  • Loading branch information
etagwerker authored Oct 9, 2023
2 parents 1b4b478 + e46ab51 commit d49c02a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions database_cleaner-active_record.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "mysql2"
spec.add_development_dependency "pg"
spec.add_development_dependency "sqlite3"
spec.add_development_dependency "trilogy"
end
2 changes: 1 addition & 1 deletion lib/database_cleaner/active_record/deletion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def build_table_stats_query(connection)
end

def information_schema_exists? connection
connection.adapter_name == "Mysql2"
["Mysql2", "Trilogy"].include?(connection.adapter_name)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/database_cleaner/active_record/truncation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ConnectionWrapper < SimpleDelegator
def initialize(connection)
extend AbstractAdapter
case connection.adapter_name
when "Mysql2"
when "Mysql2", "Trilogy"
extend AbstractMysqlAdapter
when "SQLite"
extend AbstractMysqlAdapter
Expand Down
4 changes: 2 additions & 2 deletions spec/database_cleaner/active_record/deletion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
subject(:strategy) { described_class.new(cache_tables: true) }

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

it 'does not cache the list of tables to be deleted from' do
if helper.db == :mysql2
if [:mysql2, :trilogy].include?(helper.db)
expect(strategy).to receive(:build_table_stats_query).twice.and_return("")
elsif helper.db == :postgres
expect(strategy.send(:connection)).to receive(:tables_with_schema).twice.and_return([])
Expand Down
2 changes: 1 addition & 1 deletion spec/support/database_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class DatabaseHelper < DatabaseCleaner::Spec::DatabaseHelper
def self.with_all_dbs &block
%w[mysql2 sqlite3 postgres].map(&:to_sym).each do |db|
%w[mysql2 sqlite3 postgres trilogy].map(&:to_sym).each do |db|
yield new(db)
end
end
Expand Down

0 comments on commit d49c02a

Please sign in to comment.