diff --git a/lib/with_advisory_lock/postgresql.rb b/lib/with_advisory_lock/postgresql.rb index 2e25ac6..330f786 100644 --- a/lib/with_advisory_lock/postgresql.rb +++ b/lib/with_advisory_lock/postgresql.rb @@ -8,12 +8,12 @@ def try_lock # pg_try_advisory_lock will either obtain the lock immediately # and return true, or return false if the lock cannot be acquired immediately sql = "SELECT pg_try_advisory_lock(#{numeric_lock}), #{Time.now.to_f}" - "t" == connection.select_value(sql).to_s + "t" == connection.execute(sql).first["pg_try_advisory_lock"].to_s end def release_lock sql = "SELECT pg_advisory_unlock(#{numeric_lock}), #{Time.now.to_f}" - "t" == connection.select_value(sql).to_s + "t" == connection.execute(sql).first["pg_advisory_unlock"].to_s end def numeric_lock(name=lock_name)