Skip to content

Commit

Permalink
mysql will lock for update
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Nov 22, 2010
1 parent 43b0b62 commit 3e928ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions History.txt
@@ -1,3 +1,9 @@
== 2.0.5 (unreleased)

* Bug fixes

* #lock will lock SELECT statements "FOR UPDATE" on mysql

== 2.0.4

* Bug fixes
Expand Down
4 changes: 4 additions & 0 deletions lib/arel/visitors/mysql.rb
Expand Up @@ -2,6 +2,10 @@ module Arel
module Visitors
class MySQL < Arel::Visitors::ToSql
private
def visit_Arel_Nodes_Lock o
"FOR UPDATE"
end

###
# :'(
# http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214
Expand Down
7 changes: 7 additions & 0 deletions test/visitors/test_mysql.rb
Expand Up @@ -22,6 +22,13 @@ module Visitors
sql = @visitor.accept(stmt)
sql.must_be_like "SELECT FROM DUAL"
end

it 'uses FOR UPDATE when locking' do
stmt = Nodes::SelectStatement.new
stmt.lock = Nodes::Lock.new
sql = @visitor.accept(stmt)
sql.must_be_like "SELECT FROM DUAL FOR UPDATE"
end
end
end
end

0 comments on commit 3e928ee

Please sign in to comment.