diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2013-05-01 11:33:11 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2013-05-01 16:36:01 -0700 |
commit | 54122067acaad39b277a5363c6d11d6804c7bf6b (patch) | |
tree | a6ef77805f609d5c8868602a095f49522034dd71 /activemodel/lib/active_model/validator.rb | |
parent | 09ac1776abc0d3482f491f2d49f47bcb3d9a4ad7 (diff) | |
download | rails-54122067acaad39b277a5363c6d11d6804c7bf6b.tar.gz rails-54122067acaad39b277a5363c6d11d6804c7bf6b.tar.bz2 rails-54122067acaad39b277a5363c6d11d6804c7bf6b.zip |
Handle aliased attributes in ActiveRecord::Relation.
When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
With the model
class Topic
alias_attribute :heading, :title
end
The call
Topic.where(heading: 'The First Topic')
should yield the same result as
Topic.where(title: 'The First Topic')
This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
Github #7839
*Godfrey Chan*
Diffstat (limited to 'activemodel/lib/active_model/validator.rb')
0 files changed, 0 insertions, 0 deletions