rails/rails — Issue #5229: scope chain broken
Author: daniel2d2art
Created: 2012-03-01 14:26:53+00:00
State: open

Hi, following chain is not working as expect:

```
$ rails c
Loading development environment (Rails 3.2.1)
irb(main):001:0> f = Foo.where('id=1')
Foo Load (7.2ms) SELECT "foos".* FROM "foos" WHERE (id=1)
=> []
irb(main):002:0> f.to_sql
=> "SELECT \"foos\".* FROM \"foos\" WHERE (id=1)"
irb(main):003:0> f.where('id=2')
Foo Load (4.0ms) SELECT "foos".* FROM "foos" WHERE (id=1) AND (id=2)
=> []
irb(main):004:0> f.to_sql
=> "SELECT \"foos\".* FROM \"foos\" WHERE (id=1)"
irb(main):005:0>

```

In (003) add new where scope chain, and output can see "WHERE (id=1) AND (id=2)" but if run to get ".to_sql" we can see it's not maintaining correct sql query on the ActiveRelation instance.