Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explictly check return from lock functions #11

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/with_advisory_lock/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down