rails/activerecord/CHANGELOG.md
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

1.1 KiB

  • 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').

    Godfrey Chan

  • Mute psql output when running rake db:schema:load.

    Godfrey Chan

  • Trigger a save on has_one association=(associate) when the associate contents have changed.

    Fix #8856.

    Chris Thompson

  • Abort a rake task when missing db/structure.sql like db:schema:load task.

    kennyj

Please check 4-0-stable for previous changes.