Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #78 from ebeigarts/master

Support locking by default and disable it only for SQLite
  • Loading branch information...
commit 6c7575f8e8e7b741c2ca30aff86fe566ee4d361f 2 parents 2aac990 + 481ccef
@tenderlove tenderlove authored
View
4 lib/arel/visitors/mysql.rb
@@ -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
View
4 lib/arel/visitors/oracle.rb
@@ -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)
View
3  lib/arel/visitors/postgresql.rb
@@ -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}"
View
5 lib/arel/visitors/sqlite.rb
@@ -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
View
3  lib/arel/visitors/to_sql.rb
@@ -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
View
2  test/test_select_manager.rb
@@ -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
View
5 test/visitors/test_sqlite.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.