diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb index cbd10c31e0..442b313593 100644 --- a/lib/arel/nodes.rb +++ b/lib/arel/nodes.rb @@ -1,6 +1,5 @@ # node require 'arel/nodes/node' -require 'arel/nodes/lock' require 'arel/nodes/select_statement' require 'arel/nodes/select_core' require 'arel/nodes/insert_statement' diff --git a/lib/arel/nodes/lock.rb b/lib/arel/nodes/lock.rb deleted file mode 100644 index f4eaf125e0..0000000000 --- a/lib/arel/nodes/lock.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Arel - module Nodes - class Lock < Arel::Nodes::Node - attr_reader :locking - def initialize locking = true - @locking = locking - end - end - end -end diff --git a/lib/arel/nodes/unary.rb b/lib/arel/nodes/unary.rb index e1576b9c99..1b1dcb1053 100644 --- a/lib/arel/nodes/unary.rb +++ b/lib/arel/nodes/unary.rb @@ -18,6 +18,7 @@ module Arel Offset On Top + Lock }.each do |name| const_set(name, Class.new(Unary)) end diff --git a/lib/arel/visitors/mysql.rb b/lib/arel/visitors/mysql.rb index 8f9c3cc809..dad4d5e3b2 100644 --- a/lib/arel/visitors/mysql.rb +++ b/lib/arel/visitors/mysql.rb @@ -3,8 +3,8 @@ module Arel class MySQL < Arel::Visitors::ToSql private def visit_Arel_Nodes_Lock o - if o.locking.is_a?(String) - o.locking + if o.expr.is_a?(String) + o.expr else "FOR UPDATE" end diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb index 45e7349fd3..68b483910e 100644 --- a/lib/arel/visitors/postgresql.rb +++ b/lib/arel/visitors/postgresql.rb @@ -3,8 +3,8 @@ module Arel class PostgreSQL < Arel::Visitors::ToSql private def visit_Arel_Nodes_Lock o - if o.locking.is_a?(String) - o.locking + if o.expr.is_a?(String) + o.expr else "FOR UPDATE" end diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb index 6d74926743..06e7bba9fb 100644 --- a/test/visitors/test_depth_first.rb +++ b/test/visitors/test_depth_first.rb @@ -63,7 +63,7 @@ module Arel end def test_lock - lock = Nodes::Lock.new + lock = Nodes::Lock.new true @visitor.accept lock assert_equal [lock], @collector.calls end diff --git a/test/visitors/test_mysql.rb b/test/visitors/test_mysql.rb index c22cbaff19..ee70d4c174 100644 --- a/test/visitors/test_mysql.rb +++ b/test/visitors/test_mysql.rb @@ -31,7 +31,7 @@ module Arel describe 'locking' do it 'defaults to FOR UPDATE when locking' do - node = Nodes::Lock.new + node = Nodes::Lock.new true @visitor.accept(node).must_be_like "FOR UPDATE" end diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb index 9ed42b1806..169510185e 100644 --- a/test/visitors/test_postgres.rb +++ b/test/visitors/test_postgres.rb @@ -9,7 +9,7 @@ module Arel describe 'locking' do it 'defaults to FOR UPDATE' do - @visitor.accept(Nodes::Lock.new).must_be_like %{ + @visitor.accept(Nodes::Lock.new(true)).must_be_like %{ FOR UPDATE } end