Module: ActiveRecordQueryParts

Defined in:
lib/active_record_query_parts.rb

Class Method Summary collapse

Class Method Details

.exclusive_row_lockObject

Acquires a pure exclusive lock on a row so no other queries can access it.


3
4
5
# File 'lib/active_record_query_parts.rb', line 3

def self.exclusive_row_lock
  " FOR UPDATE"
end

.glob_to_sql_like(text) ⇒ Object


21
22
23
24
# File 'lib/active_record_query_parts.rb', line 21

def self.glob_to_sql_like(text)
  text.tr!('*?', '%_')
  text
end

.shared_row_lockObject

Acquires a lock that allows any other selects to obtain the lock and read, but which will be escalated to an update lock when the row is updated within that transaction.


17
18
19
# File 'lib/active_record_query_parts.rb', line 17

def self.shared_row_lock
  " FOR SHARE"
end

.update_row_lockObject

Acquires a pseudo exclusive lock that blocks other selects trying to acquire the same lock, however, selects not requesting the lock can still read.


10
11
12
# File 'lib/active_record_query_parts.rb', line 10

def self.update_row_lock
  " FOR UPDATE"
end