diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-21 15:11:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-21 15:11:14 -0800 |
commit | 1c48bef21533039c81fdcaf868be518d5c16e383 (patch) | |
tree | a56c1d1c81fbc680c230b550458b3d1816252c04 /lib | |
parent | a4c10530e70fc42358cf7ea32440376f2c3c4c58 (diff) | |
parent | 6c65b0176223c90e08903ebc1a9a1075659f2c43 (diff) | |
download | rails-1c48bef21533039c81fdcaf868be518d5c16e383.tar.gz rails-1c48bef21533039c81fdcaf868be518d5c16e383.tar.bz2 rails-1c48bef21533039c81fdcaf868be518d5c16e383.zip |
Merge remote branch 'jstorimer/master' into omg
* jstorimer/master:
Allow database specific locking clauses to be used
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/nodes/lock.rb | 4 | ||||
-rw-r--r-- | lib/arel/select_manager.rb | 2 | ||||
-rw-r--r-- | lib/arel/visitors/mysql.rb | 6 | ||||
-rw-r--r-- | lib/arel/visitors/postgresql.rb | 6 |
4 files changed, 15 insertions, 3 deletions
diff --git a/lib/arel/nodes/lock.rb b/lib/arel/nodes/lock.rb index e5fb258e26..f4eaf125e0 100644 --- a/lib/arel/nodes/lock.rb +++ b/lib/arel/nodes/lock.rb @@ -1,6 +1,10 @@ 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/select_manager.rb b/lib/arel/select_manager.rb index 2747bdfda8..249ad680a7 100644 --- a/lib/arel/select_manager.rb +++ b/lib/arel/select_manager.rb @@ -40,7 +40,7 @@ module Arel def lock locking = true # FIXME: do we even need to store this? If locking is +false+ shouldn't # we just remove the node from the AST? - @ast.lock = Nodes::Lock.new + @ast.lock = Nodes::Lock.new(locking) self end diff --git a/lib/arel/visitors/mysql.rb b/lib/arel/visitors/mysql.rb index e90161eee4..8f9c3cc809 100644 --- a/lib/arel/visitors/mysql.rb +++ b/lib/arel/visitors/mysql.rb @@ -3,7 +3,11 @@ module Arel class MySQL < Arel::Visitors::ToSql private def visit_Arel_Nodes_Lock o - "FOR UPDATE" + if o.locking.is_a?(String) + o.locking + else + "FOR UPDATE" + end end ### diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb index 0e82a703ca..45e7349fd3 100644 --- a/lib/arel/visitors/postgresql.rb +++ b/lib/arel/visitors/postgresql.rb @@ -3,7 +3,11 @@ module Arel class PostgreSQL < Arel::Visitors::ToSql private def visit_Arel_Nodes_Lock o - "FOR UPDATE" + if o.locking.is_a?(String) + o.locking + else + "FOR UPDATE" + end end def visit_Arel_Nodes_SelectStatement o |