diff options
author | Arthur Taylor <arthur@aupeo.com> | 2011-04-15 16:34:18 +0200 |
---|---|---|
committer | Arthur Taylor <arthur@aupeo.com> | 2011-04-15 16:34:18 +0200 |
commit | 660f706491ac012cb133554cffeaa6b9ae6046e9 (patch) | |
tree | ed6e6c9d4b1b2c58f5ea310397edfe7efd968fe3 | |
parent | fc353baa803ba5ab2c11d71adcec358ea5c75f44 (diff) | |
download | rails-660f706491ac012cb133554cffeaa6b9ae6046e9.tar.gz rails-660f706491ac012cb133554cffeaa6b9ae6046e9.tar.bz2 rails-660f706491ac012cb133554cffeaa6b9ae6046e9.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 |