diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 15:57:06 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 15:57:06 -0800 |
commit | d7ff05e240770c1946fe4c0c1f74880ecd180b09 (patch) | |
tree | 830e76fcc9cebb0e898cae6ce1b7a65e66a59dfd | |
parent | 02eaa7ee6ea812e61681912719d3875401eeabe3 (diff) | |
parent | ef29263428eb2aa1fdc2b6b020f0d153fd17b5f3 (diff) | |
download | rails-d7ff05e240770c1946fe4c0c1f74880ecd180b09.tar.gz rails-d7ff05e240770c1946fe4c0c1f74880ecd180b09.tar.bz2 rails-d7ff05e240770c1946fe4c0c1f74880ecd180b09.zip |
Merge branch '2-0-stable'
* 2-0-stable:
making sure limit is correctly copied to update manager
-rw-r--r-- | lib/arel/crud.rb | 2 | ||||
-rw-r--r-- | lib/arel/update_manager.rb | 2 | ||||
-rw-r--r-- | test/test_update_manager.rb | 9 |
3 files changed, 11 insertions, 2 deletions
diff --git a/lib/arel/crud.rb b/lib/arel/crud.rb index e6b1cd9675..bedfb8c30c 100644 --- a/lib/arel/crud.rb +++ b/lib/arel/crud.rb @@ -12,7 +12,7 @@ module Arel end um.table relation um.set values - um.take @ast.limit + um.take @ast.limit.expr if @ast.limit um.order(*@ast.orders) um.wheres = @ctx.wheres um diff --git a/lib/arel/update_manager.rb b/lib/arel/update_manager.rb index cf24dbac92..f13aeb0a8c 100644 --- a/lib/arel/update_manager.rb +++ b/lib/arel/update_manager.rb @@ -7,7 +7,7 @@ module Arel end def take limit - @ast.limit = limit + @ast.limit = Nodes::Limit.new(limit) if limit self end diff --git a/test/test_update_manager.rb b/test/test_update_manager.rb index 5823845ba0..62a2eccaf5 100644 --- a/test/test_update_manager.rb +++ b/test/test_update_manager.rb @@ -8,6 +8,15 @@ module Arel end end + it 'handles limit properly' do + table = Table.new(:users) + um = Arel::UpdateManager.new Table.engine + um.take 10 + um.table table + um.set [[table[:name], nil]] + assert_match(/LIMIT 10/, um.to_sql) + end + describe 'set' do it "updates with null" do table = Table.new(:users) |