How should ActiveRecord behave with merging conditions from various sources? See rails/rails#9813 for background.
- clobber: conflicting condition values are replaced with the rightmost value
- append: conflicting condition values are chained into an AND query
class Person < ActiveRecord::Base
end
Example |
3.2.12 |
3.2.14.rc2 |
Expected |
Person.where(id: 1).find(2)
|
append |
append |
|
Person.where(id: [1, 3]).find(2)
|
append |
append |
|
Person.where("id = 1").find(2)
|
append |
append |
|
Person.where(name: "a").find_by_name("b")
|
append |
append |
|
class Person < ActiveRecord::Base
scope :sad, where(status: "sad")
scope :confused, where(status: "confused")
def self.frustrated
where(status: "frustrated")
end
end
Example |
3.2.12 |
3.2.14.rc2 |
Expected |
Person.where(status: "sad").where(status: "happy")
|
append |
append |
|
Person.confused.where(status: "happy")
|
append |
append |
|
Person.where(status: "happy").confused
|
clobber |
clobber |
|
Person.sad.confused
|
clobber |
clobber |
|
Person.sad.frustrated
|
append |
append |
|
class Manufacturer < ActiveRecord::Base
has_many :products
end
class Product < ActiveRecord::Base
belongs_to :manufacturer
end
Example |
3.2.12 |
3.2.14.rc2 |
Expected |
Manufacturer.find(1).products.where(manufacturer_id: 2)
|
append |
append |
|
class Person < ActiveRecord::Base
default_scope where(status: "meh")
scope :confused, where(status: "confused")
def self.frustrated
where(status: "frustrated")
end
end
Example |
3.2.12 |
3.2.14.rc2 |
Expected |
Person.confused
|
clobber |
clobber |
|
Person.frustrated
|
clobber |
clobber |
|