Permalink
Browse files

Lock should be a unary node

  • Loading branch information...
1 parent e4bfdee commit fa79262282768a7d0e2ba9cc6edca8ad8c100519 @tenderlove tenderlove committed Feb 21, 2011
View
@@ -1,10 +1,6 @@
module Arel
module Nodes
- class Lock < Arel::Nodes::Node
- attr_reader :locking
- def initialize locking = true
- @locking = locking
- end
+ class Lock < Arel::Nodes::Unary
end
end
end
@@ -3,8 +3,8 @@ module Visitors
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
@@ -3,8 +3,8 @@ module Visitors
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
@@ -56,7 +56,7 @@ def test_raises_with_object
end
def test_lock
- lock = Nodes::Lock.new
+ lock = Nodes::Lock.new true
@visitor.accept lock
assert_equal [lock], @collector.calls
end
@@ -31,7 +31,7 @@ module Visitors
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
@@ -9,7 +9,7 @@ module Visitors
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

0 comments on commit fa79262

Please sign in to comment.