diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-08 23:35:06 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-08 23:35:06 +0900 |
commit | 952ae3eca77da4632fd20ff040ca8581dbbad25d (patch) | |
tree | 9ab54d8409079421b95a095e1b47e3237352e008 /activerecord/lib | |
parent | 5f35c60f848dda275e34bc055f58031c08d7b416 (diff) | |
download | rails-952ae3eca77da4632fd20ff040ca8581dbbad25d.tar.gz rails-952ae3eca77da4632fd20ff040ca8581dbbad25d.tar.bz2 rails-952ae3eca77da4632fd20ff040ca8581dbbad25d.zip |
`supports_xxx?` returns whether a feature is supported by the backend
Rather than a configuration on the connection.
Diffstat (limited to 'activerecord/lib')
4 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index a62651daff..c2972a3b83 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -360,6 +360,10 @@ module ActiveRecord def enable_extension(name) end + def advisory_locks_enabled? # :nodoc: + supports_advisory_locks? && @advisory_locks_enabled + end + # This is meant to be implemented by the adapters that support advisory # locks # diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index ad045f85ef..88fff83a9e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -111,7 +111,7 @@ module ActiveRecord end def supports_advisory_locks? - @advisory_locks_enabled + true end def get_advisory_lock(lock_name, timeout = 0) # :nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 30e651ee63..3ee344a249 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -298,7 +298,7 @@ module ActiveRecord end def supports_advisory_locks? - @advisory_locks_enabled + true end def supports_explain? diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index d68ed3cad9..ea53324829 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -1357,7 +1357,7 @@ module ActiveRecord end def use_advisory_lock? - Base.connection.supports_advisory_locks? + Base.connection.advisory_locks_enabled? end def with_advisory_lock |