diff options
-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 |