Permalink
Browse files

Merge pull request #78 from ebeigarts/master

Support locking by default and disable it only for SQLite
  • Loading branch information...
tenderlove committed Aug 26, 2011
2 parents 2aac990 + 481ccef commit 6c7575f8e8e7b741c2ca30aff86fe566ee4d361f
@@ -28,10 +28,6 @@ def visit_Arel_Nodes_Bin o
"BINARY #{visit o.expr}"
end
- def visit_Arel_Nodes_Lock o
- visit o.expr
- end
-
###
# :'(
# http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214
@@ -3,10 +3,6 @@ module Visitors
class Oracle < Arel::Visitors::ToSql
private
- def visit_Arel_Nodes_Lock o
- visit o.expr
- end
-
def visit_Arel_Nodes_SelectStatement o
o = order_hacks(o)
@@ -2,9 +2,6 @@ module Arel
module Visitors
class PostgreSQL < Arel::Visitors::ToSql
private
- def visit_Arel_Nodes_Lock o
- visit o.expr
- end
def visit_Arel_Nodes_Matches o
"#{visit o.left} ILIKE #{visit o.right}"
@@ -2,6 +2,11 @@ module Arel
module Visitors
class SQLite < Arel::Visitors::ToSql
private
+
+ # Locks are not supported in SQLite
+ def visit_Arel_Nodes_Lock o
+ end
+
def visit_Arel_Nodes_SelectStatement o
o.limit = Arel::Nodes::Limit.new(-1) if o.offset && !o.limit
super
@@ -200,9 +200,8 @@ def visit_Arel_Nodes_Top o
""
end
- # FIXME: this does nothing on SQLLite3, but should do things on other
- # databases.
def visit_Arel_Nodes_Lock o
+ visit o.expr
end
def visit_Arel_Nodes_Grouping o
@@ -454,7 +454,7 @@ def test_join_sources
it 'adds a lock node' do
table = Table.new :users
mgr = table.from table
- mgr.lock.to_sql.must_be_like %{ SELECT FROM "users" }
+ mgr.lock.to_sql.must_be_like %{ SELECT FROM "users" FOR UPDATE }
end
end
@@ -13,6 +13,11 @@ module Visitors
sql = @visitor.accept(stmt)
sql.must_be_like "SELECT LIMIT -1 OFFSET 1"
end
+
+ it 'does not support locking' do
+ node = Nodes::Lock.new(Arel.sql('FOR UPDATE'))
+ @visitor.accept(node).must_be_nil
+ end
end
end
end

0 comments on commit 6c7575f

Please sign in to comment.