fixes bug introduced by #3329 These are the conditions necessary to reproduce the bug: - For an association, autosave => true. - An association record is being destroyed - A new association record is being created. - There is a unique index one of the association's fields. - The record being created has the same value as the record being destroyed on the indexed field. Before, the deletion of records was postponed until after all insertions/saves. Therefore the new record with the identical value in the indexed field caused a non-unique value error to be thrown at the database level. With this fix, the deletions happen first, before the insertions/saves. Therefore the record with the duplicate value is gone from the database before the new record is created, thereby avoiding the non-uniuqe value error.
1.4 KiB
-
fixes bug introduced by #3329. Now, when autosaving associations, deletions happen before inserts and saves. This prevents a 'duplicate unique value' database error that would occur if a record being created had the same value on a unique indexed field as that of a record being destroyed.
Johnny Holton
-
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)
andModel.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.