diff options
author | Arthur Taylor <arthur@aupeo.com> | 2011-04-15 22:34:18 +0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-19 00:22:12 +0800 |
commit | a318d6f5a7695bae85e7da67f423e86e164344b3 (patch) | |
tree | fc0846b2a10c674a8f694d5bcdd4abee2e8035a3 | |
parent | 3e3d4d197943d6fc30976021a0f125ba8eab1dd1 (diff) | |
download | rails-a318d6f5a7695bae85e7da67f423e86e164344b3.tar.gz rails-a318d6f5a7695bae85e7da67f423e86e164344b3.tar.bz2 rails-a318d6f5a7695bae85e7da67f423e86e164344b3.zip |
Fixed deep copy bug in SelectManager clone
-rw-r--r-- | lib/arel/select_manager.rb | 5 | ||||
-rw-r--r-- | test/test_select_manager.rb | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/arel/select_manager.rb b/lib/arel/select_manager.rb index 048cc5133d..d95a259177 100644 --- a/lib/arel/select_manager.rb +++ b/lib/arel/select_manager.rb @@ -9,6 +9,11 @@ module Arel from table end + def initialize_copy other + super + @ctx = @ast.cores.last + end + def limit @ast.limit && @ast.limit.expr end diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb index 81a32e4490..955d8e8d3a 100644 --- a/test/test_select_manager.rb +++ b/test/test_select_manager.rb @@ -187,6 +187,16 @@ module Arel m2.project "foo" mgr.to_sql.wont_equal m2.to_sql end + + it 'makes updates to the correct copy' do + table = Table.new :users, :engine => Table.engine, :as => 'foo' + mgr = table.from table + m2 = mgr.clone + m3 = m2.clone + m2.project "foo" + mgr.to_sql.wont_equal m2.to_sql + m3.to_sql.must_equal mgr.to_sql + end end describe 'initialize' do |