Skip to content

Commit

Permalink
Merge pull request #4 from tijn/adapter_name
Browse files Browse the repository at this point in the history
Fetch the adapter_name from #connection_db_config
  • Loading branch information
brendon authored Apr 7, 2024
2 parents 5be434f + e07e3f3 commit 8f53a1f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/positioning/advisory_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ def initialize(base_class, column)
@column = column.to_s

@adapters = {
"Mysql2" => Adapter.new(
"mysql2" => Adapter.new(
initialise: -> {},
aquire: -> { connection.execute "SELECT GET_LOCK(#{connection.quote(lock_name)}, -1)" },
release: -> { connection.execute "SELECT RELEASE_LOCK(#{connection.quote(lock_name)})" }
),
"PostgreSQL" => Adapter.new(
"postgresql" => Adapter.new(
initialise: -> {},
aquire: -> { connection.execute "SELECT pg_advisory_lock(#{lock_name.hex & 0x7FFFFFFFFFFFFFFF})" },
release: -> { connection.execute "SELECT pg_advisory_unlock(#{lock_name.hex & 0x7FFFFFFFFFFFFFFF})" }
),
"SQLite" => Adapter.new(
"sqlite3" => Adapter.new(
initialise: -> {
FileUtils.mkdir_p "#{Dir.pwd}/tmp"
filename = "#{Dir.pwd}/tmp/#{lock_name}.lock"
Expand Down Expand Up @@ -63,7 +63,7 @@ def connection
end

def adapter_name
connection.adapter_name
base_class.connection_db_config.adapter
end

def adapter
Expand Down

0 comments on commit 8f53a1f

Please sign in to comment.