Skip to content

Commit bcd3ea4

Browse files
authored
Merge pull request #1147 from koic/support_trilogy_adapter_for_mysql
Support the Trilogy adapter for MySQL
2 parents bd7ee99 + fccfc3e commit bcd3ea4

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1147](https://github.com/rubocop/rubocop-rails/issues/1147): Support the Trilogy adapter for MySQL. ([@koic][])

lib/rubocop/cop/mixin/database_type_resolvable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def database_from_yaml
2121
return unless database_yaml
2222

2323
case database_adapter
24-
when 'mysql2'
24+
when 'mysql2', 'trilogy'
2525
MYSQL
2626
when 'postgresql'
2727
POSTGRESQL
@@ -33,7 +33,7 @@ def database_from_env
3333
return unless url
3434

3535
case url
36-
when %r{\Amysql2://}
36+
when %r{\A(mysql2|trilogy)://}
3737
MYSQL
3838
when %r{\Apostgres(ql)?://}
3939
POSTGRESQL

lib/rubocop/cop/rails/bulk_change_table.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Rails
1414
# automatically detect an adapter from `development` environment
1515
# in `config/database.yml` or the environment variable `DATABASE_URL`
1616
# when the `Database` option is not set.
17-
# If the adapter is not `mysql2` or `postgresql`,
17+
# If the adapter is not `mysql2`, `trilogy`, or `postgresql`,
1818
# this Cop ignores offenses.
1919
#
2020
# @example

spec/rubocop/cop/rails/bulk_change_table_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,34 @@ def change
479479
end
480480
end
481481

482+
context 'trilogy' do
483+
context 'with top-level adapter configuration' do
484+
let(:yaml) do
485+
{
486+
'development' => {
487+
'adapter' => 'trilogy'
488+
}
489+
}
490+
end
491+
492+
it_behaves_like 'offense for mysql'
493+
end
494+
495+
context 'with nested adapter configuration' do
496+
let(:yaml) do
497+
{
498+
'development' => {
499+
'primary' => {
500+
'adapter' => 'trilogy'
501+
}
502+
}
503+
}
504+
end
505+
506+
it_behaves_like 'offense for mysql'
507+
end
508+
end
509+
482510
context 'postgresql' do
483511
context 'with top-level adapter configuration' do
484512
let(:yaml) do
@@ -541,6 +569,12 @@ def change
541569
it_behaves_like 'offense for mysql'
542570
end
543571

572+
context 'trilogy' do
573+
let(:database_url) { 'trilogy://localhost/my_database' }
574+
575+
it_behaves_like 'offense for mysql'
576+
end
577+
544578
context 'postgres' do
545579
let(:database_url) { 'postgres://localhost/my_database' }
546580

0 commit comments

Comments
 (0)