diff options
author | Sam Davies <seivadmas@gmail.com> | 2015-11-18 11:53:38 -0300 |
---|---|---|
committer | Sam Davies <seivadmas@gmail.com> | 2015-11-18 12:00:58 -0300 |
commit | 5ce21d4f72e72f8acdd5b849425a9475733d4d11 (patch) | |
tree | b0b55117137837f7e280cdffeaede36614032d1c /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |
parent | ce37df9cc1f2c3cdc63dc677645bdfec05c787fe (diff) | |
download | rails-5ce21d4f72e72f8acdd5b849425a9475733d4d11.tar.gz rails-5ce21d4f72e72f8acdd5b849425a9475733d4d11.tar.bz2 rails-5ce21d4f72e72f8acdd5b849425a9475733d4d11.zip |
Rename 'key' to 'lock_id' or 'lock_name' for advisory locking
- key was a poor choice of name. A key implies something that will
unlock a lock. The concept is actually more like a 'lock identifier'
- mysql documentation calls this a 'lock name'
- postgres documentation calls it a 'lock_id'
- Updated variable names to reflect the preferred terminology for the database in
question
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 3eefab8f44..719592349b 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -304,18 +304,18 @@ module ActiveRecord postgresql_version >= 90300 end - def get_advisory_lock(key) # :nodoc: - unless key.is_a?(Integer) && key.bit_length <= 63 - raise(ArgumentError, "Postgres requires advisory lock keys to be a signed 64 bit integer") + def get_advisory_lock(lock_id) # :nodoc: + unless lock_id.is_a?(Integer) && lock_id.bit_length <= 63 + raise(ArgumentError, "Postgres requires advisory lock ids to be a signed 64 bit integer") end - select_value("SELECT pg_try_advisory_lock(#{key});") + select_value("SELECT pg_try_advisory_lock(#{lock_id});") end - def release_advisory_lock(key) # :nodoc: - unless key.is_a?(Integer) && key.bit_length <= 63 - raise(ArgumentError, "Postgres requires advisory lock keys to be a signed 64 bit integer") + def release_advisory_lock(lock_id) # :nodoc: + unless lock_id.is_a?(Integer) && lock_id.bit_length <= 63 + raise(ArgumentError, "Postgres requires advisory lock ids to be a signed 64 bit integer") end - select_value("SELECT pg_advisory_unlock(#{key})") + select_value("SELECT pg_advisory_unlock(#{lock_id})") end def enable_extension(name) |