1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/active_record/relation
Godfrey Chan 54122067ac 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*
2013-05-01 16:36:01 -07:00
..
batches.rb Fix find_in_batches against string IDs when start option is not specified. 2012-10-31 15:39:24 +01:00
calculations.rb Handle aliased attributes in ActiveRecord::Relation. 2013-05-01 16:36:01 -07:00
delegation.rb add missing :nodoc: marks to ActiveRecord::Delegation [ci skip] 2013-04-29 20:32:13 -05:00
finder_methods.rb true/false => truthy falsy 2013-04-02 18:01:56 -07:00
merger.rb Remove warning 2013-04-10 21:09:45 -03:00
predicate_builder.rb Handle aliased attributes in ActiveRecord::Relation. 2013-05-01 16:36:01 -07:00
query_methods.rb When empty options passed to having clause having_values was [nil] but should be empty. 2013-04-23 17:07:49 +04:00
spawn_methods.rb refatctoring of some code repetition in spawn_methods 2012-12-31 18:45:11 +01:00