Skip to content

Commit

Permalink
fix: make select...for update locks be a no-op on cockroachdb
Browse files Browse the repository at this point in the history
In Cockroachdb there is no select for update
(see cockroachdb/cockroach#6583)
But it is not needed, make it a no-op.
  • Loading branch information
donbowman committed Sep 1, 2019
1 parent bf4fbfa commit 30e3eff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/core_ext/active_record/connection_adapters/cockroachdb/lock.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Cockroachdb does not implement the locking of select...for update.
# but, it doesn't need it since it uses serialised updates. So
# we make it a no-op
# https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/21
module ActiveRecord
class Base
def lock!(lock = true)
super(lock) unless self.class.connection.class.to_s == 'ActiveRecord::ConnectionAdapters::CockroachDBAdapter'
end
end
end

0 comments on commit 30e3eff

Please sign in to comment.