2014-02-04 14:13:14 +00:00
|
|
|
* Make sure transaction state gets reset after a commit operation on the record.
|
|
|
|
|
|
|
|
If a new transaction was open inside a callback, the record was loosing track
|
|
|
|
of the transaction level state, and it was leaking that state.
|
|
|
|
|
|
|
|
Fixes #12566.
|
|
|
|
|
|
|
|
*arthurnn*
|
|
|
|
|
2014-02-03 13:48:59 +00:00
|
|
|
* Pass `has_and_belongs_to_many` `:autosave` option to
|
|
|
|
the underlying `has_many :through` association.
|
|
|
|
|
|
|
|
Fixes #13923.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2014-02-03 13:52:01 +00:00
|
|
|
* PostgreSQL implementation of `SchemaStatements#index_name_exists?`.
|
2014-01-12 22:53:16 +00:00
|
|
|
|
|
|
|
The database agnostic implementation does not detect with indexes that are
|
|
|
|
not supported by the ActiveRecord schema dumper. For example, expressions
|
|
|
|
indexes would not be detected.
|
|
|
|
|
2014-02-03 13:52:01 +00:00
|
|
|
Fixes #11018.
|
2014-01-12 22:53:16 +00:00
|
|
|
|
|
|
|
*Jonathan Baudanza*
|
|
|
|
|
2014-02-01 04:11:03 +00:00
|
|
|
* Parsing PostgreSQL arrays with empty strings now works correctly.
|
|
|
|
|
|
|
|
Previously, if you tried to parse `{"1","","2","","3"}` the result
|
|
|
|
would be `["1","2","3"]`, removing the empty strings from the array,
|
|
|
|
which would be incorrect. Now it will correctly produce `["1","","2","","3"]`
|
|
|
|
as the result of parsing the above PostgreSQL array.
|
|
|
|
|
|
|
|
Fixes #13907.
|
|
|
|
|
|
|
|
*Maurício Linhares*
|
|
|
|
|
2014-01-31 00:58:00 +00:00
|
|
|
* Associations now raise `ArgumentError` on name conflicts.
|
|
|
|
|
|
|
|
Dangerous association names conflicts include instance or class methods already
|
|
|
|
defined by `ActiveRecord::Base`.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
class Car < ActiveRecord::Base
|
|
|
|
has_many :errors
|
|
|
|
end
|
|
|
|
# Will raise ArgumentError.
|
|
|
|
|
|
|
|
Fixes #13217.
|
|
|
|
|
|
|
|
*Lauro Caetano*
|
|
|
|
|
2014-01-30 02:17:10 +00:00
|
|
|
* Fix regressions on `select_*` methods.
|
|
|
|
When `select_*` methods receive a `Relation` object, they should be able to get the arel/binds from it.
|
2014-01-31 10:02:56 +00:00
|
|
|
Also fix regressions on `select_rows` that was ignoring the binds.
|
2014-01-30 02:17:10 +00:00
|
|
|
|
|
|
|
Fixes #7538, #12017, #13731, #12056.
|
|
|
|
|
|
|
|
*arthurnn*
|
|
|
|
|
2014-01-29 22:48:43 +00:00
|
|
|
* Active Record objects can now be correctly dumped, loaded and dumped again without issues.
|
2014-01-29 03:54:13 +00:00
|
|
|
|
|
|
|
Previously, if you did `YAML.dump`, `YAML.load` and then `YAML.dump` again
|
2014-01-31 10:02:56 +00:00
|
|
|
in an Active Record model that used serialization it would fail at the last
|
2014-01-29 03:54:13 +00:00
|
|
|
dump due to the fields not being correctly serialized before being dumped
|
|
|
|
to YAML. Now it is possible to dump and load the same object as many times
|
|
|
|
as needed without any issues.
|
|
|
|
|
|
|
|
Fixes #13861.
|
|
|
|
|
|
|
|
*Maurício Linhares*
|
|
|
|
|
2013-12-05 17:20:03 +00:00
|
|
|
* `find_in_batches` now returns an `Enumerator` when called without a block, so that it
|
|
|
|
can be chained with other `Enumerable` methods.
|
|
|
|
|
|
|
|
*Marc-André Lafortune*
|
|
|
|
|
2014-01-31 10:02:56 +00:00
|
|
|
* `enum` now raises on "dangerous" name conflicts.
|
2014-01-27 09:39:52 +00:00
|
|
|
|
|
|
|
Dangerous name conflicts includes instance or class method conflicts
|
|
|
|
with methods defined within `ActiveRecord::Base` but not its ancestors,
|
|
|
|
as well as conflicts with methods generated by other enums on the same
|
|
|
|
class.
|
|
|
|
|
|
|
|
Fixes #13389.
|
|
|
|
|
|
|
|
*Godfrey Chan*
|
|
|
|
|
2014-01-31 10:02:56 +00:00
|
|
|
* `scope` now raises on "dangerous" name conflicts.
|
2014-01-25 02:28:05 +00:00
|
|
|
|
|
|
|
Similar to dangerous attribute methods, a scope name conflict is
|
|
|
|
dangerous if it conflicts with an existing class method defined within
|
|
|
|
`ActiveRecord::Base` but not its ancestors.
|
|
|
|
|
|
|
|
See also #13389.
|
|
|
|
|
|
|
|
*Godfrey Chan*, *Philippe Creux*
|
|
|
|
|
2014-01-29 04:56:20 +00:00
|
|
|
* Correctly send an user provided statement to a `lock!()` call.
|
|
|
|
|
|
|
|
person.lock! 'FOR SHARE NOWAIT'
|
|
|
|
# Before: SELECT * ... LIMIT 1 FOR UPDATE
|
|
|
|
# After: SELECT * ... LIMIT 1 FOR SHARE NOWAIT
|
|
|
|
|
|
|
|
Fixes #13788.
|
|
|
|
|
|
|
|
*Maurício Linhares*
|
|
|
|
|
2013-08-09 14:46:27 +00:00
|
|
|
* Handle aliased attributes `select()`, `order()` and `reorder()`.
|
|
|
|
|
|
|
|
*Tsutomu Kuroda*
|
|
|
|
|
2014-01-22 15:25:12 +00:00
|
|
|
* Reset the collection association when calling `reset` on it.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
post.comments.loaded? # => true
|
|
|
|
post.comments.reset
|
|
|
|
post.comments.loaded? # => true
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
post.comments.loaded? # => true
|
|
|
|
post.comments.reset
|
|
|
|
post.comments.loaded? # => false
|
2014-01-22 02:19:51 +00:00
|
|
|
|
|
|
|
Fixes #13777.
|
2014-01-22 15:25:12 +00:00
|
|
|
|
2014-01-22 02:19:51 +00:00
|
|
|
*Kelsey Schlarman*
|
|
|
|
|
2014-01-20 23:59:20 +00:00
|
|
|
* Make enum fields work as expected with the `ActiveModel::Dirty` API.
|
|
|
|
|
|
|
|
Before this change, using the dirty API would have surprising results:
|
|
|
|
|
|
|
|
conversation = Conversation.new
|
|
|
|
conversation.status = :active
|
|
|
|
conversation.status = :archived
|
|
|
|
conversation.status_was # => 0
|
|
|
|
|
|
|
|
After this change, the same code would result in:
|
|
|
|
|
|
|
|
conversation = Conversation.new
|
|
|
|
conversation.status = :active
|
|
|
|
conversation.status = :archived
|
|
|
|
conversation.status_was # => "active"
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2014-01-21 16:33:16 +00:00
|
|
|
* `has_one` and `belongs_to` accessors don't add ORDER BY to the queries anymore.
|
|
|
|
|
|
|
|
Since Rails 4.0, we add an ORDER BY in the `first` method to ensure consistent results
|
|
|
|
among different database engines. But for singular associations this behavior is not needed
|
|
|
|
since we will have one record to return. As this ORDER BY option can lead some performance
|
|
|
|
issues we are removing it for singular associations accessors.
|
|
|
|
|
|
|
|
Fixes #12623.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2014-01-21 16:17:13 +00:00
|
|
|
* Prepend table name for column names passed to `Relation#select`.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
Post.select(:id)
|
|
|
|
# Before: => SELECT id FROM "posts"
|
|
|
|
# After: => SELECT "posts"."id" FROM "posts"
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-03-28 12:03:02 +00:00
|
|
|
* Fail early with "Primary key not included in the custom select clause"
|
2014-01-21 13:35:33 +00:00
|
|
|
in `find_in_batches`.
|
2013-03-28 12:03:02 +00:00
|
|
|
|
2014-01-21 13:35:33 +00:00
|
|
|
Before this patch, the exception was raised after the first batch was
|
|
|
|
yielded to the block. This means that you only get it, when you hit the
|
|
|
|
`batch_size` treshold. This could shadow the issue in development.
|
2013-03-28 12:03:02 +00:00
|
|
|
|
|
|
|
*Alexander Balashov*
|
|
|
|
|
2014-01-18 05:51:34 +00:00
|
|
|
* Ensure `second` through `fifth` methods act like the `first` finder.
|
|
|
|
|
|
|
|
The famous ordinal Array instance methods defined in ActiveSupport
|
|
|
|
(`first`, `second`, `third`, `fourth`, and `fifth`) are now available as
|
|
|
|
full-fledged finders in ActiveRecord. The biggest benefit of this is ordering
|
|
|
|
of the records returned now defaults to the table's primary key in ascending order.
|
|
|
|
|
2014-01-21 13:35:33 +00:00
|
|
|
Fixes #13743.
|
|
|
|
|
2014-01-18 05:51:34 +00:00
|
|
|
Example:
|
|
|
|
|
|
|
|
User.all.second
|
|
|
|
|
|
|
|
# Before
|
|
|
|
# => 'SELECT "users".* FROM "users"'
|
|
|
|
|
|
|
|
# After
|
|
|
|
# => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 1'
|
|
|
|
|
|
|
|
User.offset(3).second
|
|
|
|
|
|
|
|
# Before
|
|
|
|
# => 'SELECT "users".* FROM "users" LIMIT -1 OFFSET 3' # sqlite3 gem
|
|
|
|
# => 'SELECT "users".* FROM "users" OFFSET 3' # pg gem
|
|
|
|
# => 'SELECT `users`.* FROM `users` LIMIT 18446744073709551615 OFFSET 3' # mysql2 gem
|
|
|
|
|
|
|
|
# After
|
|
|
|
# => SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 OFFSET 4'
|
|
|
|
|
|
|
|
*Jason Meller*
|
|
|
|
|
Restore ActiveRecord states after a rollback for models w/o callbacks
This fixes a regression (#13744) that was caused by 67d8bb9.
In 67d8bb9, we introduced lazy rollback for records, such that the
record's internal states and attributes are not restored immediately
after a transaction rollback, but deferred until they are first
accessed.
This optimization is only performed when the model does not have any
transactional callbacks (e.g. `after_commit` and `after_create`).
Unfortunately, the models used to test the affected codepaths all
comes with some sort of transactional callbacks. Therefore this
codepath remains largely untested until now and as a result there are
a few issues in the implementation that remains hidden until now.
First, the `sync_with_transaction_state` (or more accurately,
`update_attributes_from_transaction_state`) would perform the
synchronization prematurely before a transaction is finalized (i.e.
comitted or rolled back). As a result, when the actuall rollback
happens, the record will incorrectly assumes that its internal states
match the transaction state, and neglect to perform the restore.
Second, `update_attributes_from_transaction_state` calls `committed!`
in some cases. This in turns checks for the `destroyed?` state which
also requires synchronization with the transaction stae, which causes
an infnite recurrsion.
This fix works by deferring the synchronization until the transaction
has been finalized (addressing the first point), and also unrolled
the `committed!` and `rolledback!` logic in-place (addressing the
second point).
It should be noted that the primary purpose of the `committed!` and
`rolledback!` methods are to trigger the relevant transactional
callbacks. Since this code path is only entered when there are no
transactional callbacks on the model, this shouldn't be necessary. By
unrolling the method calls, the intention here (to restore the states
when necessary) becomes more clear.
2014-01-18 12:36:45 +00:00
|
|
|
* ActiveRecord states are now correctly restored after a rollback for
|
|
|
|
models that did not define any transactional callbacks (i.e.
|
|
|
|
`after_commit`, `after_rollback` or `after_create`).
|
|
|
|
|
|
|
|
Fixes #13744.
|
|
|
|
|
|
|
|
*Godfrey Chan*
|
|
|
|
|
2013-08-26 17:15:37 +00:00
|
|
|
* Make `touch` fire the `after_commit` and `after_rollback` callbacks.
|
|
|
|
|
|
|
|
*Harry Brundage*
|
|
|
|
|
2013-12-17 17:10:23 +00:00
|
|
|
* Enable partial indexes for sqlite >= 3.8.0
|
|
|
|
|
|
|
|
See http://www.sqlite.org/partialindex.html
|
|
|
|
|
|
|
|
*Cody Cutrer*
|
|
|
|
|
2014-01-14 13:23:45 +00:00
|
|
|
* Don't try to get the subclass if the inheritance column doesn't exist
|
|
|
|
|
|
|
|
The `subclass_from_attrs` method is called even if the column specified by
|
|
|
|
the `inheritance_column` setting doesn't exist. This prevents setting associations
|
|
|
|
via the attributes hash if the association name clashes with the value of the setting,
|
|
|
|
typically `:type`. This worked previously in Rails 3.2.
|
|
|
|
|
|
|
|
*Ujjwal Thaakar*
|
|
|
|
|
2014-01-14 11:58:22 +00:00
|
|
|
* Enum mappings are now exposed via class methods instead of constants.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
class Conversation < ActiveRecord::Base
|
|
|
|
enum status: [ :active, :archived ]
|
|
|
|
end
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
Conversation::STATUS # => { "active" => 0, "archived" => 1 }
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
Conversation.statuses # => { "active" => 0, "archived" => 1 }
|
|
|
|
|
|
|
|
*Godfrey Chan*
|
|
|
|
|
2014-01-14 08:19:37 +00:00
|
|
|
* Set `NameError#name` when STI-class-lookup fails.
|
2014-01-11 00:27:18 +00:00
|
|
|
|
|
|
|
*Chulki Lee*
|
|
|
|
|
2014-01-13 14:04:23 +00:00
|
|
|
* Fix bug in `becomes!` when changing from the base model to a STI sub-class.
|
|
|
|
|
|
|
|
Fixes #13272.
|
|
|
|
|
|
|
|
*the-web-dev*, *Yves Senn*
|
|
|
|
|
2014-01-01 22:33:59 +00:00
|
|
|
* Currently Active Record can be configured via the environment variable
|
|
|
|
`DATABASE_URL` or by manually injecting a hash of values which is what Rails does,
|
|
|
|
reading in `database.yml` and setting Active Record appropriately. Active Record
|
|
|
|
expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot
|
|
|
|
rip out this functionality without deprecating. This presents a problem though
|
|
|
|
when both config is set, and a `DATABASE_URL` is present. Currently the
|
|
|
|
`DATABASE_URL` should "win" and none of the values in `database.yml` are
|
|
|
|
used. This is somewhat unexpected, if one were to set values such as
|
|
|
|
`pool` in the `production:` group of `database.yml` they are ignored.
|
|
|
|
|
|
|
|
There are many ways that Active Record initiates a connection today:
|
|
|
|
|
|
|
|
- Stand Alone (without rails)
|
|
|
|
- `rake db:<tasks>`
|
|
|
|
- `ActiveRecord.establish_connection`
|
|
|
|
|
|
|
|
- With Rails
|
|
|
|
- `rake db:<tasks>`
|
|
|
|
- `rails <server> | <console>`
|
|
|
|
- `rails dbconsole`
|
|
|
|
|
|
|
|
Now all of these behave exactly the same way. The best way to do
|
|
|
|
this is to put all of this logic in one place so it is guaranteed to be used.
|
|
|
|
|
|
|
|
Here is the matrix of how this behavior works:
|
|
|
|
|
|
|
|
```
|
|
|
|
No database.yml
|
|
|
|
No DATABASE_URL
|
|
|
|
=> Error
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
database.yml present
|
|
|
|
No DATABASE_URL
|
|
|
|
=> Use database.yml configuration
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
No database.yml
|
|
|
|
DATABASE_URL present
|
|
|
|
=> use DATABASE_URL configuration
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
database.yml present
|
|
|
|
DATABASE_URL present
|
|
|
|
=> Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url`
|
|
|
|
sub key "wins". If other paramaters `adapter` or `database` are specified in YAML,
|
|
|
|
they are discarded as the `url` sub key "wins".
|
|
|
|
```
|
|
|
|
|
|
|
|
Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge
|
|
|
|
all connection information before returning. This is achieved through a utility
|
|
|
|
class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`.
|
|
|
|
|
|
|
|
To understand the exact behavior of this class, it is best to review the
|
2014-01-14 08:19:37 +00:00
|
|
|
behavior in `activerecord/test/cases/connection_adapters/connection_handler_test.rb`.
|
2014-01-01 22:33:59 +00:00
|
|
|
|
|
|
|
*Richard Schneeman*
|
|
|
|
|
2014-01-08 14:51:06 +00:00
|
|
|
* Make `change_column_null` revertable. Fixes #13576.
|
|
|
|
|
|
|
|
*Yves Senn*, *Nishant Modak*, *Prathamesh Sonpatki*
|
|
|
|
|
2014-01-08 15:40:49 +00:00
|
|
|
* Don't create/drop the test database if RAILS_ENV is specified explicitly.
|
2014-01-08 10:08:08 +00:00
|
|
|
|
|
|
|
Previously, when the environment was development, we would always
|
|
|
|
create or drop both the test and development databases.
|
|
|
|
|
2014-01-08 15:40:49 +00:00
|
|
|
Now, if RAILS_ENV is explicitly defined as development, we don't create
|
2014-01-08 10:08:08 +00:00
|
|
|
the test database.
|
|
|
|
|
|
|
|
*Damien Mathieu*
|
|
|
|
|
2013-12-17 21:02:52 +00:00
|
|
|
* Initialize version on Migration objects so that it can be used in a migration,
|
|
|
|
and it will be included in the announce message.
|
|
|
|
|
|
|
|
*Dylan Thacker-Smith*
|
|
|
|
|
2014-01-06 09:04:22 +00:00
|
|
|
* `change_table` now uses the current adapter's `update_table_definition`
|
|
|
|
method to retrieve a specific table definition.
|
|
|
|
This ensures that `change_table` and `create_table` will use
|
|
|
|
similar objects.
|
2014-01-07 20:44:00 +00:00
|
|
|
|
2014-01-06 09:04:22 +00:00
|
|
|
Fixes #13577 and #13503.
|
|
|
|
|
|
|
|
*Nishant Modak*, *Prathamesh Sonpatki*, *Rafael Mendonça França*
|
|
|
|
|
2014-01-05 22:55:02 +00:00
|
|
|
* Fixed ActiveRecord::Store nil conversion TypeError when using YAML coder.
|
|
|
|
In case the YAML passed as paramter is nil, uses an empty string.
|
|
|
|
|
|
|
|
Fixes #13570.
|
|
|
|
|
|
|
|
*Thales Oliveira*
|
|
|
|
|
2014-01-03 15:31:20 +00:00
|
|
|
* Deprecate unused `ActiveRecord::Base.symbolized_base_class`
|
|
|
|
and `ActiveRecord::Base.symbolized_sti_name` without replacement.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2014-01-08 15:40:49 +00:00
|
|
|
* Since the `test_help.rb` file in Railties now automatically maintains
|
2013-12-29 11:05:04 +00:00
|
|
|
your test schema, the `rake db:test:*` tasks are deprecated. This
|
|
|
|
doesn't stop you manually running other tasks on your test database
|
|
|
|
if needed:
|
|
|
|
|
|
|
|
rake db:schema:load RAILS_ENV=test
|
|
|
|
|
|
|
|
*Jon Leighton*
|
|
|
|
|
2014-01-01 21:08:28 +00:00
|
|
|
* Fix presence validator for association when the associated record responds to `to_a`.
|
|
|
|
|
|
|
|
*gmarik*
|
|
|
|
|
2013-12-30 21:14:27 +00:00
|
|
|
* Fixed regression on preload/includes with multiple arguments failing in certain conditions,
|
|
|
|
raising a NoMethodError internally by calling `reflect_on_association` for `NilClass:Class`.
|
|
|
|
|
|
|
|
Fixes #13437.
|
|
|
|
|
|
|
|
*Vipul A M*, *khustochka*
|
|
|
|
|
2013-12-20 12:12:59 +00:00
|
|
|
* Add the ability to nullify the `enum` column.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
class Conversation < ActiveRecord::Base
|
|
|
|
enum gender: [:female, :male]
|
|
|
|
end
|
|
|
|
|
|
|
|
Conversation::GENDER # => { female: 0, male: 1 }
|
|
|
|
|
|
|
|
# conversation.update! gender: 0
|
|
|
|
conversation.female!
|
|
|
|
conversation.female? # => true
|
|
|
|
conversation.gender # => "female"
|
|
|
|
|
|
|
|
# conversation.update! gender: nil
|
|
|
|
conversation.gender = nil
|
|
|
|
conversation.gender.nil? # => true
|
|
|
|
conversation.gender # => nil
|
|
|
|
|
|
|
|
*Amr Tamimi*
|
|
|
|
|
2013-12-30 16:26:28 +00:00
|
|
|
* Connection specification now accepts a "url" key. The value of this
|
|
|
|
key is expected to contain a database URL. The database URL will be
|
|
|
|
expanded into a hash and merged.
|
|
|
|
|
|
|
|
*Richard Schneeman*
|
|
|
|
|
2013-12-30 10:40:21 +00:00
|
|
|
* An `ArgumentError` is now raised on a call to `Relation#where.not(nil)`.
|
|
|
|
|
2013-12-30 11:18:45 +00:00
|
|
|
Example:
|
|
|
|
|
2013-12-30 10:40:21 +00:00
|
|
|
User.where.not(nil)
|
|
|
|
|
|
|
|
# Before
|
|
|
|
# => 'SELECT `users`.* FROM `users` WHERE (NOT (NULL))'
|
|
|
|
|
|
|
|
# After
|
|
|
|
# => ArgumentError, 'Invalid argument for .where.not(), got nil.'
|
|
|
|
|
|
|
|
*Kuldeep Aggarwal*
|
|
|
|
|
2013-12-30 11:18:45 +00:00
|
|
|
* Deprecated use of string argument as a configuration lookup in
|
|
|
|
`ActiveRecord::Base.establish_connection`. Instead, a symbol must be given.
|
2013-12-24 09:18:54 +00:00
|
|
|
|
|
|
|
*José Valim*
|
|
|
|
|
2013-09-28 15:10:59 +00:00
|
|
|
* Fixed `update_column`, `update_columns`, and `update_all` to correctly serialize
|
2013-12-20 10:45:54 +00:00
|
|
|
values for `array`, `hstore` and `json` column types in PostgreSQL.
|
2013-09-28 15:10:59 +00:00
|
|
|
|
|
|
|
Fixes #12261.
|
|
|
|
|
2013-12-20 10:45:54 +00:00
|
|
|
*Tadas Tamosauskas*, *Carlos Antonio da Silva*
|
2013-09-28 15:10:59 +00:00
|
|
|
|
2013-12-19 19:39:20 +00:00
|
|
|
* Do not consider PostgreSQL array columns as number or text columns.
|
|
|
|
|
|
|
|
The code uses these checks in several places to know what to do with a
|
|
|
|
particular column, for instance AR attribute query methods has a branch
|
|
|
|
like this:
|
|
|
|
|
|
|
|
if column.number?
|
|
|
|
!value.zero?
|
|
|
|
end
|
|
|
|
|
|
|
|
This should never be true for array columns, since it would be the same
|
|
|
|
as running [].zero?, which results in a NoMethodError exception.
|
|
|
|
|
|
|
|
Fixing this by ensuring that array columns in PostgreSQL never return
|
|
|
|
true for number?/text? checks.
|
|
|
|
|
|
|
|
*Carlos Antonio da Silva*
|
|
|
|
|
2013-12-24 15:12:08 +00:00
|
|
|
* When connecting to a non-existant database, the error:
|
2013-11-11 20:56:09 +00:00
|
|
|
`ActiveRecord::NoDatabaseError` will now be raised. When being used with Rails
|
|
|
|
the error message will include information on how to create a database:
|
2013-12-24 15:12:08 +00:00
|
|
|
`rake db:create`. Supported adapters: postgresql, mysql, mysql2, sqlite3
|
2013-11-11 20:56:09 +00:00
|
|
|
|
|
|
|
*Richard Schneeman*
|
|
|
|
|
2014-01-03 22:02:31 +00:00
|
|
|
* Do not raise `'cannot touch on a new record object'` exception on destroying
|
2013-12-30 11:18:45 +00:00
|
|
|
already destroyed `belongs_to` association with `touch: true` option.
|
2013-12-22 16:18:40 +00:00
|
|
|
|
2013-12-30 11:18:45 +00:00
|
|
|
Fixes #13445.
|
2013-12-22 16:18:40 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
# Given Comment has belongs_to :post, touch: true
|
|
|
|
comment.post.destroy
|
|
|
|
comment.destroy # no longer raises an error
|
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-12-22 17:44:42 +00:00
|
|
|
* Fix a bug when assigning an array containing string numbers to a
|
|
|
|
PostgreSQL integer array column.
|
|
|
|
|
|
|
|
Fixes #13444.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
# Given Book#ratings is of type :integer, array: true
|
|
|
|
Book.new(ratings: [1, 2]) # worked before
|
|
|
|
Book.new(ratings: ['1', '2']) # now works as well
|
|
|
|
|
|
|
|
*Damien Mathieu*
|
|
|
|
|
2013-12-19 21:53:26 +00:00
|
|
|
* Improve the default select when `from` is used.
|
2013-12-17 04:26:37 +00:00
|
|
|
|
|
|
|
Previously, if you did something like Topic.from(:temp_topics), it
|
|
|
|
would generate SQL like:
|
|
|
|
|
2013-12-19 21:53:26 +00:00
|
|
|
SELECT topics.* FROM temp_topics;
|
2013-12-17 04:26:37 +00:00
|
|
|
|
2013-12-19 21:53:26 +00:00
|
|
|
Which is will cause an error since there's not a topics table to select
|
|
|
|
from.
|
2013-12-17 04:26:37 +00:00
|
|
|
|
2013-12-19 21:53:26 +00:00
|
|
|
Now the default if you use from is just `*`:
|
2013-12-17 04:26:37 +00:00
|
|
|
|
2013-12-19 21:53:26 +00:00
|
|
|
SELECT * FROM temp_topics;
|
2013-12-17 04:26:37 +00:00
|
|
|
|
|
|
|
*Cody Cutrer*
|
|
|
|
|
2013-12-19 13:16:17 +00:00
|
|
|
* Fix `PostgreSQL` insert to properly extract table name from multiline string SQL.
|
|
|
|
|
|
|
|
Previously, executing an insert SQL in `PostgreSQL` with a command like this:
|
|
|
|
|
|
|
|
insert into articles(
|
|
|
|
number)
|
|
|
|
values(
|
|
|
|
5152
|
|
|
|
)
|
|
|
|
|
|
|
|
would not work because the adapter was unable to extract the correct `articles`
|
|
|
|
table name.
|
|
|
|
|
|
|
|
*Kuldeep Aggarwal*
|
|
|
|
|
2013-12-14 00:11:39 +00:00
|
|
|
* `Relation` no longer has mutator methods like `#map!` and `#delete_if`. Convert
|
|
|
|
to an `Array` by calling `#to_a` before using these methods.
|
|
|
|
|
|
|
|
It intends to prevent odd bugs and confusion in code that call mutator
|
|
|
|
methods directly on the `Relation`.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
# Instead of this
|
|
|
|
Author.where(name: 'Hank Moody').compact!
|
|
|
|
|
|
|
|
# Now you have to do this
|
|
|
|
authors = Author.where(name: 'Hank Moody').to_a
|
|
|
|
authors.compact!
|
|
|
|
|
|
|
|
*Lauro Caetano*
|
|
|
|
|
Better support for `where()` conditions that use an association name.
Using the name of an association in `where` previously worked only
if the value was a single `ActiveRecrd::Base` object. e.g.
Post.where(author: Author.first)
Any other values, including `nil`, would cause invalid SQL to be
generated. This change supports arguments in the `where` query
conditions where the key is a `belongs_to` association name and the
value is `nil`, an `Array` of `ActiveRecord::Base` objects, or an
`ActiveRecord::Relation` object.
# Given the Post model
class Post < ActiveRecord::Base
belongs_to :author
end
# nil value finds records where the association is not set
Post.where(author: nil)
# SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IS NULL
# Array values find records where the association foreign key
# matches the ids of the passed ActiveRecord models, resulting
# in the same query as Post.where(author_id: [1,2])
authors_array = [Author.find(1), Author.find(2)]
Post.where(author: authors_array)
# ActiveRecord::Relation values find records using the same
# query as Post.where(author_id: Author.where(last_name: "Emde"))
Post.where(author: Author.where(last_name: "Emde"))
Polymorphic `belongs_to` associations will continue to be handled
appropriately, with the polymorphic `association_type` field added
to the query to match the base class of the value. This feature
previously only worked when the value was a single `ActveRecord::Base`.
class Post < ActiveRecord::Base
belongs_to :author, polymorphic: true
end
Post.where(author: Author.where(last_name: "Emde"))
# Generates a query similar to:
Post.where(author_id: Author.where(last_name: "Emde"), author_type: "Author")
2013-12-16 22:16:15 +00:00
|
|
|
* Better support for `where()` conditions that use a `belongs_to`
|
|
|
|
association name.
|
|
|
|
|
|
|
|
Using the name of an association in `where` previously worked only
|
|
|
|
if the value was a single `ActiveRecord::Base` object. e.g.
|
|
|
|
|
|
|
|
Post.where(author: Author.first)
|
|
|
|
|
|
|
|
Any other values, including `nil`, would cause invalid SQL to be
|
|
|
|
generated. This change supports arguments in the `where` query
|
|
|
|
conditions where the key is a `belongs_to` association name and the
|
|
|
|
value is `nil`, an `Array` of `ActiveRecord::Base` objects, or an
|
|
|
|
`ActiveRecord::Relation` object.
|
|
|
|
|
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
belongs_to :author
|
|
|
|
end
|
|
|
|
|
|
|
|
`nil` value finds records where the association is not set:
|
|
|
|
|
|
|
|
Post.where(author: nil)
|
|
|
|
# SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IS NULL
|
|
|
|
|
|
|
|
`Array` values find records where the association foreign key
|
|
|
|
matches the ids of the passed ActiveRecord models, resulting
|
|
|
|
in the same query as `Post.where(author_id: [1,2])`:
|
|
|
|
|
|
|
|
authors_array = [Author.find(1), Author.find(2)]
|
|
|
|
Post.where(author: authors_array)
|
|
|
|
# SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IN (1, 2)
|
|
|
|
|
|
|
|
`ActiveRecord::Relation` values find records using the same
|
|
|
|
query as `Post.where(author_id: Author.where(last_name: "Emde"))`
|
|
|
|
|
|
|
|
Post.where(author: Author.where(last_name: "Emde"))
|
|
|
|
# SELECT "posts".* FROM "posts"
|
|
|
|
# WHERE "posts"."author_id" IN (
|
|
|
|
# SELECT "authors"."id" FROM "authors"
|
|
|
|
# WHERE "authors"."last_name" = 'Emde')
|
|
|
|
|
|
|
|
Polymorphic `belongs_to` associations will continue to be handled
|
|
|
|
appropriately, with the polymorphic `association_type` field added
|
|
|
|
to the query to match the base class of the value. This feature
|
|
|
|
previously only worked when the value was a single `ActveRecord::Base`.
|
|
|
|
|
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
belongs_to :author, polymorphic: true
|
|
|
|
end
|
|
|
|
|
|
|
|
Post.where(author: Author.where(last_name: "Emde"))
|
|
|
|
# Generates a query similar to:
|
|
|
|
Post.where(author_id: Author.where(last_name: "Emde"), author_type: "Author")
|
|
|
|
|
|
|
|
*Martin Emde*
|
|
|
|
|
2013-12-15 19:07:31 +00:00
|
|
|
* Respect temporary option when dropping tables with MySQL.
|
2013-12-13 22:20:03 +00:00
|
|
|
|
|
|
|
Normal DROP TABLE also works, but commits the transaction.
|
|
|
|
|
2013-12-15 19:07:44 +00:00
|
|
|
drop_table :temporary_table, temporary: true
|
|
|
|
|
2013-12-13 22:20:03 +00:00
|
|
|
*Cody Cutrer*
|
|
|
|
|
|
|
|
* Add option to create tables from a query.
|
|
|
|
|
2013-12-15 19:07:44 +00:00
|
|
|
create_table(:long_query, temporary: true,
|
|
|
|
as: "SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id")
|
|
|
|
|
|
|
|
Generates:
|
|
|
|
|
|
|
|
CREATE TEMPORARY TABLE long_query AS
|
|
|
|
SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id
|
|
|
|
|
2013-12-13 22:20:03 +00:00
|
|
|
*Cody Cutrer*
|
|
|
|
|
2013-12-15 18:46:12 +00:00
|
|
|
* `db:test:clone` and `db:test:prepare` must load Rails environment.
|
2013-12-13 21:04:46 +00:00
|
|
|
|
2013-12-15 18:46:12 +00:00
|
|
|
`db:test:clone` and `db:test:prepare` use `ActiveRecord::Base`. configurations,
|
|
|
|
so we need to load the Rails environment, otherwise the config wont be in place.
|
2013-12-13 21:04:46 +00:00
|
|
|
|
|
|
|
*arthurnn*
|
|
|
|
|
2013-12-08 23:23:38 +00:00
|
|
|
* Use the right column to type cast grouped calculations with custom expressions.
|
|
|
|
|
2013-12-12 10:33:46 +00:00
|
|
|
Fixes #13230.
|
2013-12-08 23:23:38 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2013-12-12 10:33:46 +00:00
|
|
|
# Before
|
|
|
|
Account.group(:firm_name).sum('0.01 * credit_limit')
|
|
|
|
# => { '37signals' => '0.5' }
|
2013-12-08 23:23:38 +00:00
|
|
|
|
2013-12-12 10:33:46 +00:00
|
|
|
# After
|
|
|
|
Account.group(:firm_name).sum('0.01 * credit_limit')
|
|
|
|
# => { '37signals' => 0.5 }
|
2013-12-08 23:23:38 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-12-05 21:29:47 +00:00
|
|
|
* Polymorphic `belongs_to` associations with the `touch: true` option set update the timestamps of
|
2013-12-05 14:57:05 +00:00
|
|
|
the old and new owner correctly when moved between owners of different types.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
class Rating < ActiveRecord::Base
|
|
|
|
belongs_to :rateable, polymorphic: true, touch: true
|
|
|
|
end
|
|
|
|
|
|
|
|
rating = Rating.create rateable: Song.find(1)
|
|
|
|
rating.update_attributes rateable: Book.find(2) # => timestamps of Song(1) and Book(2) are updated
|
|
|
|
|
|
|
|
*Severin Schoepke*
|
|
|
|
|
2013-12-03 20:16:30 +00:00
|
|
|
* Improve formatting of migration exception messages: make them easier to read
|
|
|
|
with line breaks before/after, and improve the error for pending migrations.
|
|
|
|
|
|
|
|
*John Bachir*
|
|
|
|
|
|
|
|
* Fix `last` with `offset` to return the proper record instead of always the last one.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
Model.offset(4).last
|
|
|
|
# => returns the 4th record from the end.
|
2013-12-03 18:33:34 +00:00
|
|
|
|
|
|
|
Fixes #7441.
|
|
|
|
|
2013-12-03 20:16:30 +00:00
|
|
|
*kostya*, *Lauro Caetano*
|
2013-12-03 18:33:34 +00:00
|
|
|
|
2013-12-03 16:54:25 +00:00
|
|
|
* `type_to_sql` returns a `String` for unmapped columns. This fixes an error
|
2014-01-14 08:19:37 +00:00
|
|
|
when using unmapped PostgreSQL array types.
|
2013-12-03 16:54:25 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
change_colum :table, :column, :bigint, array: true
|
|
|
|
|
|
|
|
Fixes #13146.
|
|
|
|
|
|
|
|
*Jens Fahnenbruck*, *Yves Senn*
|
|
|
|
|
2013-07-28 19:42:34 +00:00
|
|
|
* Fix `QueryCache` to work with nested blocks, so that it will only clear the existing cache
|
|
|
|
after leaving the outer block instead of clearing it right after the inner block is finished.
|
|
|
|
|
|
|
|
*Vipul A M*
|
|
|
|
|
2013-11-24 17:52:53 +00:00
|
|
|
* The ERB in fixture files is no longer evaluated in the context of the main
|
|
|
|
object. Helper methods used by multiple fixtures should be defined on the
|
|
|
|
class object returned by `ActiveRecord::FixtureSet.context_class`.
|
|
|
|
|
|
|
|
*Victor Costan*
|
|
|
|
|
2013-11-30 15:35:28 +00:00
|
|
|
* Previously, the `has_one` macro incorrectly accepted the `counter_cache`
|
|
|
|
option, but never actually supported it. Now it will raise an `ArgumentError`
|
|
|
|
when using `has_one` with `counter_cache`.
|
2013-11-30 03:21:49 +00:00
|
|
|
|
|
|
|
*Godfrey Chan*
|
|
|
|
|
2013-11-30 15:35:28 +00:00
|
|
|
* Implement `rename_index` natively for MySQL >= 5.7.
|
2013-11-25 20:15:15 +00:00
|
|
|
|
|
|
|
*Cody Cutrer*
|
|
|
|
|
2013-11-26 22:52:48 +00:00
|
|
|
* Fix bug when validating the uniqueness of an aliased attribute.
|
|
|
|
|
|
|
|
Fixes #12402.
|
|
|
|
|
|
|
|
*Lauro Caetano*
|
|
|
|
|
2013-11-30 15:35:28 +00:00
|
|
|
* Update counter cache on a `has_many` relationship regardless of default scope.
|
2013-11-24 09:47:17 +00:00
|
|
|
|
2014-01-14 08:19:37 +00:00
|
|
|
Fixes #12952.
|
2013-11-24 09:47:17 +00:00
|
|
|
|
|
|
|
*Uku Taht*
|
|
|
|
|
2013-11-30 15:35:28 +00:00
|
|
|
* `rename_index` adds the new index before removing the old one. This allows to
|
|
|
|
rename indexes on columns with a foreign key and prevents the following error:
|
2013-11-26 08:58:24 +00:00
|
|
|
|
2013-11-30 15:35:28 +00:00
|
|
|
Cannot drop index 'index_engines_on_car_id': needed in a foreign key constraint
|
2013-11-26 08:58:24 +00:00
|
|
|
|
|
|
|
*Cody Cutrer*, *Yves Senn*
|
|
|
|
|
2014-01-14 08:19:37 +00:00
|
|
|
* Raise `ActiveRecord::RecordNotDestroyed` when a replaced child
|
|
|
|
marked with `dependent: destroy` fails to be destroyed.
|
2013-11-26 01:17:31 +00:00
|
|
|
|
2014-01-14 08:19:37 +00:00
|
|
|
Fixex #12812.
|
2013-11-26 01:17:31 +00:00
|
|
|
|
|
|
|
*Brian Thomas Storti*
|
|
|
|
|
2013-11-05 14:36:48 +00:00
|
|
|
* Fix validation on uniqueness of empty association.
|
|
|
|
|
|
|
|
*Evgeny Li*
|
|
|
|
|
2013-11-22 10:30:03 +00:00
|
|
|
* Make `ActiveRecord::Relation#unscope` affect relations it is merged in to.
|
Fix ActiveRecord::Relation#unscope
I'm pretty confused about the addition of this method. The documentation
says that it was intended to allow the removal of values from the
default scope (in contrast to #except). However it behaves exactly the
same as except: https://gist.github.com/jonleighton/7537008 (other than
having a slightly enhanced syntax).
The removal of the default scope is allowed by
94924dc32baf78f13e289172534c2e71c9c8cade, which was not a change we
could make until 4.1 due to the need to deprecate things. However after
that change #unscope still gives us nothing that #except doesn't already
give us.
However there *is* a desire to be able to unscope stuff in a way that
persists across merges, which would allow associations to be defined
which unscope stuff from the default scope of the associated model. E.g.
has_many :comments, -> { unscope where: :trashed }
So that's what this change implements. I've also corrected the
documentation. I removed the guide references to #except as I think
unscope really supercedes #except now.
While we're here, there's also a potential desire to be able to write
this:
has_many :comments, -> { unscoped }
However, it doesn't make sense and would not be straightforward to
implement. While with #unscope we're specifying exactly what we want to
be removed from the relation, with "unscoped" we're just saying that we
want it to not have some things which were added earlier on by the
default scope. However in the case of an association, we surely don't
want *all* conditions to be removed, otherwise the above would just
become "SELECT * FROM comments" with no foreign key constraint.
To make the above work, we'd have to somehow tag the relation values
which get added when evaluating the default scope in order to
differentiate them from other relation values. Which is way too much
complexity and therefore not worth it when most use cases can be
satisfied with unscope.
Closes #10643, #11061.
2013-11-20 21:51:35 +00:00
|
|
|
|
|
|
|
*Jon Leighton*
|
|
|
|
|
2013-11-13 16:26:55 +00:00
|
|
|
* Use strings to represent non-string `order_values`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-11-16 20:28:03 +00:00
|
|
|
* Checks to see if the record contains the foreign key to set the inverse automatically.
|
2013-11-16 20:18:02 +00:00
|
|
|
|
|
|
|
*Edo Balvers*
|
|
|
|
|
2013-11-14 18:38:08 +00:00
|
|
|
* Added `ActiveRecord::Base.to_param` for convenient "pretty" URLs derived from a model's attribute or method.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2013-11-15 01:24:32 +00:00
|
|
|
class User < ActiveRecord::Base
|
|
|
|
to_param :name
|
|
|
|
end
|
2013-11-14 18:38:08 +00:00
|
|
|
|
2013-11-15 01:24:32 +00:00
|
|
|
user = User.find_by(name: 'Fancy Pants')
|
|
|
|
user.id # => 123
|
|
|
|
user.to_param # => "123-fancy-pants"
|
2013-11-14 18:38:08 +00:00
|
|
|
|
|
|
|
*Javan Makhmali*
|
|
|
|
|
2013-11-05 12:44:16 +00:00
|
|
|
* Added `ActiveRecord::Base.no_touching`, which allows ignoring touch on models.
|
|
|
|
|
2013-11-15 01:24:32 +00:00
|
|
|
Example:
|
2013-11-05 12:44:16 +00:00
|
|
|
|
2013-11-15 01:24:32 +00:00
|
|
|
Post.no_touching do
|
|
|
|
Post.first.touch
|
|
|
|
end
|
2013-11-05 12:44:16 +00:00
|
|
|
|
|
|
|
*Sam Stephenson*, *Damien Mathieu*
|
|
|
|
|
2013-11-11 16:41:54 +00:00
|
|
|
* Prevent the counter cache from being decremented twice when destroying
|
2013-11-15 01:24:32 +00:00
|
|
|
a record on a `has_many :through` association.
|
2013-11-11 16:41:54 +00:00
|
|
|
|
|
|
|
Fixes #11079.
|
|
|
|
|
|
|
|
*Dmitry Dedov*
|
|
|
|
|
2013-08-07 15:59:27 +00:00
|
|
|
* Unify boolean type casting for `MysqlAdapter` and `Mysql2Adapter`.
|
|
|
|
`type_cast` will return `1` for `true` and `0` for `false`.
|
|
|
|
|
|
|
|
Fixes #11119.
|
|
|
|
|
|
|
|
*Adam Williams*, *Yves Senn*
|
|
|
|
|
2013-11-25 18:26:57 +00:00
|
|
|
* Fix bug where `has_one` association record update result in crash, when replaced with itself.
|
2013-11-09 15:38:27 +00:00
|
|
|
|
|
|
|
Fixes #12834.
|
|
|
|
|
|
|
|
*Denis Redozubov*, *Sergio Cambra*
|
|
|
|
|
2013-11-09 10:09:20 +00:00
|
|
|
* Log bind variables after they are type casted. This makes it more
|
|
|
|
transparent what values are actually sent to the database.
|
|
|
|
|
|
|
|
irb(main):002:0> Event.find("im-no-integer")
|
|
|
|
# Before: ... WHERE "events"."id" = $1 LIMIT 1 [["id", "im-no-integer"]]
|
|
|
|
# After: ... WHERE "events"."id" = $1 LIMIT 1 [["id", 0]]
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-11-09 18:44:32 +00:00
|
|
|
* Fix uninitialized constant `TransactionState` error when `Marshall.load` is used on an Active Record result.
|
2013-11-11 11:03:36 +00:00
|
|
|
|
|
|
|
Fixes #12790.
|
2013-11-07 01:22:53 +00:00
|
|
|
|
|
|
|
*Jason Ayre*
|
|
|
|
|
2013-11-03 00:09:10 +00:00
|
|
|
* `.unscope` now removes conditions specified in `default_scope`.
|
|
|
|
|
|
|
|
*Jon Leighton*
|
|
|
|
|
2013-11-09 18:44:32 +00:00
|
|
|
* Added `ActiveRecord::QueryMethods#rewhere` which will overwrite an existing, named where condition.
|
2013-11-03 00:35:34 +00:00
|
|
|
|
2013-11-04 14:42:45 +00:00
|
|
|
Examples:
|
2013-11-03 00:35:34 +00:00
|
|
|
|
2013-11-04 14:42:45 +00:00
|
|
|
Post.where(trashed: true).where(trashed: false) #=> WHERE `trashed` = 1 AND `trashed` = 0
|
|
|
|
Post.where(trashed: true).rewhere(trashed: false) #=> WHERE `trashed` = 0
|
|
|
|
Post.where(active: true).where(trashed: true).rewhere(trashed: false) #=> WHERE `active` = 1 AND `trashed` = 0
|
|
|
|
|
|
|
|
*DHH*
|
2013-11-03 00:35:34 +00:00
|
|
|
|
2013-11-09 18:44:32 +00:00
|
|
|
* Extend `ActiveRecord::Base#cache_key` to take an optional list of timestamp attributes of which the highest will be used.
|
2013-11-02 23:05:19 +00:00
|
|
|
|
2013-11-03 00:09:10 +00:00
|
|
|
Example:
|
2013-11-02 23:05:19 +00:00
|
|
|
|
2013-11-03 00:09:10 +00:00
|
|
|
# last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
|
|
|
|
Person.find(5).cache_key(:updated_at, :last_reviewed_at)
|
2013-11-02 23:05:19 +00:00
|
|
|
|
2013-11-03 00:09:10 +00:00
|
|
|
*DHH*
|
2013-11-02 23:05:19 +00:00
|
|
|
|
2013-11-09 18:44:32 +00:00
|
|
|
* Added `ActiveRecord::Base#enum` for declaring enum attributes where the values map to integers in the database, but can be queried by name.
|
2013-11-02 19:01:31 +00:00
|
|
|
|
2013-11-02 20:08:36 +00:00
|
|
|
Example:
|
|
|
|
|
|
|
|
class Conversation < ActiveRecord::Base
|
|
|
|
enum status: [:active, :archived]
|
|
|
|
end
|
|
|
|
|
|
|
|
Conversation::STATUS # => { active: 0, archived: 1 }
|
|
|
|
|
|
|
|
# conversation.update! status: 0
|
|
|
|
conversation.active!
|
|
|
|
conversation.active? # => true
|
2013-11-09 18:44:32 +00:00
|
|
|
conversation.status # => "active"
|
2013-11-02 20:08:36 +00:00
|
|
|
|
|
|
|
# conversation.update! status: 1
|
|
|
|
conversation.archived!
|
|
|
|
conversation.archived? # => true
|
2013-11-09 18:44:32 +00:00
|
|
|
conversation.status # => "archived"
|
2013-11-02 20:08:36 +00:00
|
|
|
|
|
|
|
# conversation.update! status: 1
|
|
|
|
conversation.status = :archived
|
|
|
|
|
|
|
|
*DHH*
|
2013-11-02 19:01:31 +00:00
|
|
|
|
2013-11-09 18:44:32 +00:00
|
|
|
* `ActiveRecord::Base#attribute_for_inspect` now truncates long arrays (more than 10 elements).
|
2013-10-26 14:01:37 +00:00
|
|
|
|
|
|
|
*Jan Bernacki*
|
|
|
|
|
2013-11-09 18:44:32 +00:00
|
|
|
* Allow for the name of the `schema_migrations` table to be configured.
|
2013-10-18 00:00:22 +00:00
|
|
|
|
|
|
|
*Jerad Phelps*
|
|
|
|
|
2013-10-27 17:39:22 +00:00
|
|
|
* Do not add to scope includes values from through associations.
|
|
|
|
Fixed bug when providing `includes` in through association scope, and fetching targets.
|
|
|
|
|
|
|
|
Example:
|
2013-11-02 20:08:36 +00:00
|
|
|
|
2013-10-27 17:39:22 +00:00
|
|
|
class Vendor < ActiveRecord::Base
|
|
|
|
has_many :relationships, -> { includes(:user) }
|
|
|
|
has_many :users, through: :relationships
|
|
|
|
end
|
|
|
|
|
|
|
|
vendor = Vendor.first
|
|
|
|
|
|
|
|
# Before
|
|
|
|
|
|
|
|
vendor.users.to_a # => Raises exception: not found `:user` for `User`
|
|
|
|
|
|
|
|
# After
|
|
|
|
|
|
|
|
vendor.users.to_a # => No exception is raised
|
|
|
|
|
2013-10-30 17:21:56 +00:00
|
|
|
Fixes #12242, #9517, #10240.
|
2013-10-27 17:39:22 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-10-25 12:45:52 +00:00
|
|
|
* Type cast json values on write, so that the value is consistent
|
|
|
|
with reading from the database.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
x = JsonDataType.new tags: {"string" => "foo", :symbol => :bar}
|
|
|
|
|
|
|
|
# Before:
|
|
|
|
x.tags # => {"string" => "foo", :symbol => :bar}
|
|
|
|
|
|
|
|
# After:
|
|
|
|
x.tags # => {"string" => "foo", "symbol" => "bar"}
|
|
|
|
|
|
|
|
*Severin Schoepke*
|
|
|
|
|
2014-02-03 13:52:01 +00:00
|
|
|
* `ActiveRecord::Store` works together with PostgreSQL `hstore` columns.
|
2013-11-11 11:03:36 +00:00
|
|
|
|
2013-10-10 12:41:14 +00:00
|
|
|
Fixes #12452.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-10-10 08:32:52 +00:00
|
|
|
* Fix bug where `ActiveRecord::Store` used a global `Hash` to keep track of
|
|
|
|
all registered `stored_attributes`. Now every subclass of
|
|
|
|
`ActiveRecord::Base` has it's own `Hash`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-10-24 02:06:49 +00:00
|
|
|
* Save `has_one` association when primary key is manually set.
|
|
|
|
|
2013-10-25 00:37:29 +00:00
|
|
|
Fixes #12302.
|
2013-10-24 02:06:49 +00:00
|
|
|
|
|
|
|
*Lauro Caetano*
|
|
|
|
|
2013-10-28 02:48:50 +00:00
|
|
|
* Allow any version of BCrypt when using `has_secure_password`.
|
2013-10-24 21:33:18 +00:00
|
|
|
|
|
|
|
*Mike Perham*
|
|
|
|
|
2013-10-18 20:26:39 +00:00
|
|
|
* Sub-query generated for `Relation` passed as array condition did not take in account
|
|
|
|
bind values and have invalid syntax.
|
|
|
|
|
|
|
|
Generate sub-query with inline bind values.
|
|
|
|
|
2013-10-22 07:36:49 +00:00
|
|
|
Fixes #12586.
|
2013-10-18 20:26:39 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-10-21 17:30:05 +00:00
|
|
|
* Fix a bug where rake db:structure:load crashed when the path contained
|
|
|
|
spaces.
|
|
|
|
|
|
|
|
*Kevin Mook*
|
|
|
|
|
2013-10-16 18:39:43 +00:00
|
|
|
* `ActiveRecord::QueryMethods#unscope` unscopes negative equality
|
|
|
|
|
2013-10-22 07:36:49 +00:00
|
|
|
Allows you to call `#unscope` on a relation with negative equality
|
2013-10-16 18:39:43 +00:00
|
|
|
operators, i.e. `Arel::Nodes::NotIn` and `Arel::Nodes::NotEqual` that have
|
|
|
|
been generated through the use of `where.not`.
|
2013-10-21 21:13:04 +00:00
|
|
|
|
2013-10-16 18:39:43 +00:00
|
|
|
*Eric Hankins*
|
2013-10-21 21:13:04 +00:00
|
|
|
|
2013-10-15 18:58:45 +00:00
|
|
|
* Raise an exception when model without primary key calls `.find_with_ids`.
|
|
|
|
|
|
|
|
*Shimpei Makimoto*
|
|
|
|
|
2013-10-14 17:51:29 +00:00
|
|
|
* Make `Relation#empty?` use `exists?` instead of `count`.
|
|
|
|
|
|
|
|
*Szymon Nowak*
|
|
|
|
|
2013-08-11 05:27:16 +00:00
|
|
|
* `rake db:structure:dump` no longer crashes when the port was specified as `Fixnum`.
|
|
|
|
|
|
|
|
*Kenta Okamoto*
|
|
|
|
|
2013-10-15 17:04:58 +00:00
|
|
|
* `NullRelation#pluck` takes a list of columns
|
|
|
|
|
|
|
|
The method signature in `NullRelation` was updated to mimic that in
|
|
|
|
`Calculations`.
|
|
|
|
|
|
|
|
*Derek Prior*
|
|
|
|
|
2013-05-09 17:08:44 +00:00
|
|
|
* `scope_chain` should not be mutated for other reflections.
|
|
|
|
|
|
|
|
Currently `scope_chain` uses same array for building different
|
|
|
|
`scope_chain` for different associations. During processing
|
|
|
|
these arrays are sometimes mutated and because of in-place
|
|
|
|
mutation the changed `scope_chain` impacts other reflections.
|
|
|
|
|
|
|
|
Fix is to dup the value before adding to the `scope_chain`.
|
|
|
|
|
|
|
|
Fixes #3882.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-10-13 20:54:07 +00:00
|
|
|
* Prevent the inversed association from being reloaded on save.
|
|
|
|
|
|
|
|
Fixes #9499.
|
|
|
|
|
|
|
|
*Dmitry Polushkin*
|
|
|
|
|
2013-10-14 07:47:21 +00:00
|
|
|
* Generate subquery for `Relation` if it passed as array condition for `where`
|
|
|
|
method.
|
2013-10-12 11:38:37 +00:00
|
|
|
|
|
|
|
Example:
|
2013-10-14 07:47:21 +00:00
|
|
|
|
2013-10-12 11:38:37 +00:00
|
|
|
# Before
|
|
|
|
Blog.where('id in (?)', Blog.where(id: 1))
|
|
|
|
# => SELECT "blogs".* FROM "blogs" WHERE "blogs"."id" = 1
|
|
|
|
# => SELECT "blogs".* FROM "blogs" WHERE (id IN (1))
|
|
|
|
|
|
|
|
# After
|
|
|
|
Blog.where('id in (?)', Blog.where(id: 1).select(:id))
|
|
|
|
# => SELECT "blogs".* FROM "blogs"
|
|
|
|
# WHERE "blogs"."id" IN (SELECT "blogs"."id" FROM "blogs" WHERE "blogs"."id" = 1)
|
|
|
|
|
2013-10-14 07:47:21 +00:00
|
|
|
Fixes #12415.
|
2013-10-12 11:38:37 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-10-12 13:39:09 +00:00
|
|
|
* For missed association exception message
|
|
|
|
which is raised in `ActiveRecord::Associations::Preloader` class
|
|
|
|
added owner record class name in order to simplify to find problem code.
|
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-10-02 23:06:59 +00:00
|
|
|
* `has_and_belongs_to_many` is now transparently implemented in terms of
|
|
|
|
`has_many :through`. Behavior should remain the same, if not, it is a bug.
|
|
|
|
|
2013-09-30 08:58:25 +00:00
|
|
|
* `create_savepoint`, `rollback_to_savepoint` and `release_savepoint` accept
|
|
|
|
a savepoint name.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-09-27 14:16:58 +00:00
|
|
|
* Make `next_migration_number` accessible for third party generators.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-10-03 05:16:41 +00:00
|
|
|
* Objects instantiated using a null relationship will now retain the
|
2013-07-14 14:32:56 +00:00
|
|
|
attributes of the where clause.
|
|
|
|
|
2013-10-02 13:36:20 +00:00
|
|
|
Fixes #11676, #11675, #11376.
|
2013-07-14 14:32:56 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*, *Peter Brown*, *Nthalk*
|
|
|
|
|
2013-09-25 23:19:10 +00:00
|
|
|
* Fixed `ActiveRecord::Associations::CollectionAssociation#find`
|
|
|
|
when using `has_many` association with `:inverse_of` and finding an array of one element,
|
|
|
|
it should return an array of one element too.
|
|
|
|
|
|
|
|
*arthurnn*
|
|
|
|
|
2013-09-25 18:46:24 +00:00
|
|
|
* Callbacks on has_many should access the in memory parent if a inverse_of is set.
|
|
|
|
|
|
|
|
*arthurnn*
|
|
|
|
|
2013-09-19 15:13:33 +00:00
|
|
|
* `ActiveRecord::ConnectionAdapters.string_to_time` respects
|
|
|
|
string with timezone (e.g. Wed, 04 Sep 2013 20:30:00 JST).
|
2013-09-25 18:46:24 +00:00
|
|
|
|
2013-10-02 13:36:20 +00:00
|
|
|
Fixes #12278.
|
2013-09-19 15:13:33 +00:00
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-03-21 21:10:17 +00:00
|
|
|
* Calling `update_attributes` will now throw an `ArgumentError` whenever it
|
|
|
|
gets a `nil` argument. More specifically, it will throw an error if the
|
|
|
|
argument that it gets passed does not respond to to `stringify_keys`.
|
|
|
|
|
2013-09-24 14:56:50 +00:00
|
|
|
Example:
|
2013-03-21 21:10:17 +00:00
|
|
|
|
2013-09-24 14:56:50 +00:00
|
|
|
@my_comment.update_attributes(nil) # => raises ArgumentError
|
2013-03-21 21:10:17 +00:00
|
|
|
|
|
|
|
*John Wang*
|
|
|
|
|
2013-07-13 17:12:33 +00:00
|
|
|
* Deprecate `quoted_locking_column` method, which isn't used anywhere.
|
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-07-09 17:14:38 +00:00
|
|
|
* Migration dump UUID default functions to schema.rb.
|
2013-09-22 19:01:01 +00:00
|
|
|
|
2013-07-09 17:14:38 +00:00
|
|
|
Fixes #10751.
|
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-09-22 17:38:39 +00:00
|
|
|
* Fixed a bug in `ActiveRecord::Associations::CollectionAssociation#find_by_scan`
|
|
|
|
when using `has_many` association with `:inverse_of` option and UUID primary key.
|
|
|
|
|
2013-05-07 16:24:50 +00:00
|
|
|
Fixes #10450.
|
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-08-24 16:12:05 +00:00
|
|
|
* Fix: joins association, with defined in the scope block constraints by using several
|
|
|
|
where constraints and at least of them is not `Arel::Nodes::Equality`,
|
|
|
|
generates invalid SQL expression.
|
|
|
|
|
2013-10-02 13:36:20 +00:00
|
|
|
Fixes #11963.
|
2013-08-24 16:12:05 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-09-04 23:47:28 +00:00
|
|
|
* `CollectionAssociation#first`/`#last` (e.g. `has_many`) use a `LIMIT`ed
|
|
|
|
query to fetch results rather than loading the entire collection.
|
|
|
|
|
|
|
|
*Lann Martin*
|
|
|
|
|
2013-09-12 23:21:59 +00:00
|
|
|
* Make possible to run SQLite rake tasks without the `Rails` constant defined.
|
|
|
|
|
|
|
|
*Damien Mathieu*
|
|
|
|
|
2013-09-06 22:16:39 +00:00
|
|
|
* Allow Relation#from to accept other relations with bind values.
|
|
|
|
|
|
|
|
*Ryan Wallace*
|
|
|
|
|
2013-08-28 02:41:29 +00:00
|
|
|
* Fix inserts with prepared statements disabled.
|
|
|
|
|
|
|
|
Fixes #12023.
|
|
|
|
|
|
|
|
*Rafael Mendonça França*
|
|
|
|
|
2013-09-04 22:36:28 +00:00
|
|
|
* Setting a has_one association on a new record no longer causes an empty
|
|
|
|
transaction.
|
|
|
|
|
|
|
|
*Dylan Thacker-Smith*
|
|
|
|
|
2013-09-11 12:18:31 +00:00
|
|
|
* Fix `AR::Relation#merge` sometimes failing to preserve `readonly(false)` flag.
|
|
|
|
|
|
|
|
*thedarkone*
|
|
|
|
|
2013-08-21 07:49:18 +00:00
|
|
|
* Re-use `order` argument pre-processing for `reorder`.
|
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-09-08 22:55:35 +00:00
|
|
|
* Fix PredicateBuilder so polymorphic association keys in `where` clause can
|
|
|
|
accept objects other than direct descendants of `ActiveRecord::Base` (decorated
|
2013-08-20 11:21:23 +00:00
|
|
|
models, for example).
|
|
|
|
|
|
|
|
*Mikhail Dieterle*
|
|
|
|
|
2013-08-26 09:14:56 +00:00
|
|
|
* PostgreSQL adapter recognizes negative money values formatted with
|
|
|
|
parentheses (eg. `($1.25) # => -1.25`)).
|
|
|
|
Fixes #11899.
|
|
|
|
|
2013-08-30 04:00:42 +00:00
|
|
|
*Yves Senn*
|
2013-08-26 09:14:56 +00:00
|
|
|
|
2013-08-20 16:24:48 +00:00
|
|
|
* Stop interpreting SQL 'string' columns as :string type because there is no
|
|
|
|
common STRING datatype in SQL.
|
|
|
|
|
|
|
|
*Ben Woosley*
|
|
|
|
|
2013-08-19 12:39:51 +00:00
|
|
|
* `ActiveRecord::FinderMethods#exists?` returns `true`/`false` in all cases.
|
|
|
|
|
|
|
|
*Xavier Noria*
|
|
|
|
|
2013-07-23 19:33:53 +00:00
|
|
|
* Assign inet/cidr attribute with `nil` value for invalid address.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
record = User.new
|
|
|
|
record.logged_in_from_ip # is type of an inet or a cidr
|
|
|
|
|
|
|
|
# Before:
|
|
|
|
record.logged_in_from_ip = 'bad ip address' # raise exception
|
|
|
|
|
|
|
|
# After:
|
|
|
|
record.logged_in_from_ip = 'bad ip address' # do not raise exception
|
|
|
|
record.logged_in_from_ip # => nil
|
|
|
|
record.logged_in_from_ip_before_type_cast # => 'bad ip address'
|
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-07-21 00:23:45 +00:00
|
|
|
* `add_to_target` now accepts a second optional `skip_callbacks` argument
|
|
|
|
|
|
|
|
If truthy, it will skip the :before_add and :after_add callbacks.
|
|
|
|
|
|
|
|
*Ben Woosley*
|
|
|
|
|
2012-03-16 11:26:24 +00:00
|
|
|
* Fix interactions between `:before_add` callbacks and nested attributes
|
|
|
|
assignment of `has_many` associations, when the association was not
|
|
|
|
yet loaded:
|
|
|
|
|
|
|
|
- A `:before_add` callback was being called when a nested attributes
|
|
|
|
assignment assigned to an existing record.
|
|
|
|
|
|
|
|
- Nested Attributes assignment did not affect the record in the
|
|
|
|
association target when a `:before_add` callback triggered the
|
|
|
|
loading of the association
|
|
|
|
|
|
|
|
*Jörg Schray*
|
|
|
|
|
2013-08-10 07:25:04 +00:00
|
|
|
* Allow enable_extension migration method to be revertible.
|
2012-03-16 11:26:24 +00:00
|
|
|
|
2013-08-10 07:25:04 +00:00
|
|
|
*Eric Tipton*
|
|
|
|
|
2013-08-07 13:17:15 +00:00
|
|
|
* Type cast hstore values on write, so that the value is consistent
|
|
|
|
with reading from the database.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
x = Hstore.new tags: {"bool" => true, "number" => 5}
|
|
|
|
|
|
|
|
# Before:
|
|
|
|
x.tags # => {"bool" => true, "number" => 5}
|
|
|
|
|
|
|
|
# After:
|
|
|
|
x.tags # => {"bool" => "true", "number" => "5"}
|
|
|
|
|
|
|
|
*Yves Senn* , *Severin Schoepke*
|
|
|
|
|
2014-02-03 13:52:01 +00:00
|
|
|
* Fix multidimensional PostgreSQL arrays containing non-string items.
|
2013-08-07 16:21:45 +00:00
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-08-09 10:58:46 +00:00
|
|
|
* Fixes bug when using includes combined with select, the select statement was overwritten.
|
|
|
|
|
2013-10-22 07:36:49 +00:00
|
|
|
Fixes #11773.
|
2013-08-09 10:58:46 +00:00
|
|
|
|
|
|
|
*Edo Balvers*
|
|
|
|
|
2013-08-06 12:22:39 +00:00
|
|
|
* Load fixtures from linked folders.
|
|
|
|
|
|
|
|
*Kassio Borges*
|
|
|
|
|
2013-08-05 15:12:12 +00:00
|
|
|
* Create a directory for sqlite3 file if not present on the system.
|
|
|
|
|
|
|
|
*Richard Schneeman*
|
|
|
|
|
2014-02-03 13:52:01 +00:00
|
|
|
* Removed redundant override of `xml` column definition for PostgreSQL,
|
2013-08-02 12:45:12 +00:00
|
|
|
in order to use `xml` column type instead of `text`.
|
2013-08-02 07:27:37 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*, *Michael Nikitochkin*
|
|
|
|
|
2013-07-30 02:18:33 +00:00
|
|
|
* Revert `ActiveRecord::Relation#order` change that make new order
|
|
|
|
prepend the old one.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
User.order("name asc").order("created_at desc")
|
|
|
|
# SELECT * FROM users ORDER BY created_at desc, name asc
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
User.order("name asc").order("created_at desc")
|
|
|
|
# SELECT * FROM users ORDER BY name asc, created_at desc
|
|
|
|
|
|
|
|
This also affects order defined in `default_scope` or any kind of associations.
|
|
|
|
|
2013-05-18 00:23:57 +00:00
|
|
|
* Add ability to define how a class is converted to Arel predicates.
|
|
|
|
For example, adding a very vendor specific regex implementation:
|
|
|
|
|
|
|
|
regex_handler = proc do |column, value|
|
|
|
|
Arel::Nodes::InfixOperation.new('~', column, value.source)
|
|
|
|
end
|
|
|
|
ActiveRecord::PredicateBuilder.register_handler(Regexp, regex_handler)
|
|
|
|
|
|
|
|
*Sean Griffin & @joannecheng*
|
|
|
|
|
2013-07-21 03:30:35 +00:00
|
|
|
* Don't allow `quote_value` to be called without a column.
|
|
|
|
|
|
|
|
Some adapters require column information to do their job properly.
|
|
|
|
By enforcing the provision of the column for this internal method
|
|
|
|
we ensure that those using adapters that require column information
|
|
|
|
will always get the proper behavior.
|
|
|
|
|
|
|
|
*Ben Woosley*
|
|
|
|
|
2013-07-21 03:15:48 +00:00
|
|
|
* When using optimistic locking, `update` was not passing the column to `quote_value`
|
2012-06-17 15:43:31 +00:00
|
|
|
to allow the connection adapter to properly determine how to quote the value. This was
|
2013-08-02 07:03:35 +00:00
|
|
|
affecting certain databases that use specific column types.
|
2013-07-21 03:15:48 +00:00
|
|
|
|
2013-10-02 13:36:20 +00:00
|
|
|
Fixes #6763.
|
2012-06-17 15:43:31 +00:00
|
|
|
|
|
|
|
*Alfred Wong*
|
|
|
|
|
2013-07-21 20:11:41 +00:00
|
|
|
* rescue from all exceptions in `ConnectionManagement#call`
|
|
|
|
|
2013-10-02 13:36:20 +00:00
|
|
|
Fixes #11497.
|
2013-07-21 20:11:41 +00:00
|
|
|
|
|
|
|
As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does
|
|
|
|
not rescue from Exception (but only from StandardError), the Connection
|
|
|
|
Pool quickly runs out of connections when multiple erroneous Requests come
|
|
|
|
in right after each other.
|
|
|
|
|
|
|
|
Rescuing from all exceptions and not just StandardError, fixes this
|
|
|
|
behaviour.
|
|
|
|
|
|
|
|
*Vipul A M*
|
|
|
|
|
2013-07-16 07:49:55 +00:00
|
|
|
* `change_column` for PostgreSQL adapter respects the `:array` option.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-03 21:11:54 +00:00
|
|
|
* Remove deprecation warning from `attribute_missing` for attributes that are columns.
|
|
|
|
|
|
|
|
*Arun Agrawal*
|
|
|
|
|
2013-07-08 09:31:07 +00:00
|
|
|
* Remove extra decrement of transaction deep level.
|
|
|
|
|
2013-10-02 13:36:20 +00:00
|
|
|
Fixes #4566.
|
2013-07-08 09:31:07 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-07-13 18:02:47 +00:00
|
|
|
* Reset @column_defaults when assigning `locking_column`.
|
|
|
|
We had a potential problem. For example:
|
|
|
|
|
2013-10-16 13:53:43 +00:00
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
self.column_defaults # if we call this unintentionally before setting locking_column ...
|
|
|
|
self.locking_column = 'my_locking_column'
|
|
|
|
end
|
2013-07-13 18:02:47 +00:00
|
|
|
|
2013-10-16 13:53:43 +00:00
|
|
|
Post.column_defaults["my_locking_column"]
|
|
|
|
=> nil # expected value is 0 !
|
2013-07-13 18:02:47 +00:00
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-07-04 22:13:59 +00:00
|
|
|
* Remove extra select and update queries on save/touch/destroy ActiveRecord model
|
|
|
|
with belongs to reflection with option `touch: true`.
|
|
|
|
|
2013-10-02 13:36:20 +00:00
|
|
|
Fixes #11288.
|
2013-07-04 22:13:59 +00:00
|
|
|
|
|
|
|
*Paul Nikitochkin*
|
|
|
|
|
2013-07-04 08:16:11 +00:00
|
|
|
* Remove deprecated nil-passing to the following `SchemaCache` methods:
|
|
|
|
`primary_keys`, `tables`, `columns` and `columns_hash`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-04 08:02:20 +00:00
|
|
|
* Remove deprecated block filter from `ActiveRecord::Migrator#migrate`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-04 07:49:03 +00:00
|
|
|
* Remove deprecated String constructor from `ActiveRecord::Migrator`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-03 19:48:52 +00:00
|
|
|
* Remove deprecated `scope` use without passing a callable object.
|
|
|
|
|
|
|
|
*Arun Agrawal*
|
|
|
|
|
2013-07-03 18:52:56 +00:00
|
|
|
* Remove deprecated `transaction_joinable=` in favor of `begin_transaction`
|
|
|
|
with `:joinable` option.
|
|
|
|
|
|
|
|
*Arun Agrawal*
|
|
|
|
|
2013-07-03 19:40:20 +00:00
|
|
|
* Remove deprecated `decrement_open_transactions`.
|
|
|
|
|
|
|
|
*Arun Agrawal*
|
|
|
|
|
2013-07-03 18:48:49 +00:00
|
|
|
* Remove deprecated `increment_open_transactions`.
|
|
|
|
|
|
|
|
*Arun Agrawal*
|
|
|
|
|
2013-07-03 18:49:57 +00:00
|
|
|
* Remove deprecated `PostgreSQLAdapter#outside_transaction?`
|
|
|
|
method. You can use `#transaction_open?` instead.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-03 03:14:04 +00:00
|
|
|
* Remove deprecated `ActiveRecord::Fixtures.find_table_name` in favor of
|
|
|
|
`ActiveRecord::Fixtures.default_fixture_model_name`.
|
|
|
|
|
|
|
|
*Vipul A M*
|
|
|
|
|
2013-07-03 02:49:15 +00:00
|
|
|
* Removed deprecated `columns_for_remove` from `SchemaStatements`.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-02 21:41:17 +00:00
|
|
|
* Remove deprecated `SchemaStatements#distinct`.
|
|
|
|
|
|
|
|
*Francesco Rodriguez*
|
|
|
|
|
2013-07-02 20:08:04 +00:00
|
|
|
* Move deprecated `ActiveRecord::TestCase` into the rails test
|
|
|
|
suite. The class is no longer public and is only used for internal
|
|
|
|
Rails tests.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-02 19:16:39 +00:00
|
|
|
* Removed support for deprecated option `:restrict` for `:dependent`
|
|
|
|
in associations.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-02 18:38:48 +00:00
|
|
|
* Removed support for deprecated `delete_sql` in associations.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-02 18:07:08 +00:00
|
|
|
* Removed support for deprecated `insert_sql` in associations.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-02 16:26:51 +00:00
|
|
|
* Removed support for deprecated `finder_sql` in associations.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-02 14:47:36 +00:00
|
|
|
* Support array as root element in JSON fields.
|
|
|
|
|
|
|
|
*Alexey Noskov & Francesco Rodriguez*
|
|
|
|
|
2013-07-02 06:54:12 +00:00
|
|
|
* Removed support for deprecated `counter_sql` in associations.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-05-13 21:10:23 +00:00
|
|
|
* Do not invoke callbacks when `delete_all` is called on collection.
|
2013-07-02 02:41:32 +00:00
|
|
|
|
2013-05-13 21:10:23 +00:00
|
|
|
Method `delete_all` should not be invoking callbacks and this
|
|
|
|
feature was deprecated in Rails 4.0. This is being removed.
|
|
|
|
`delete_all` will continue to honor the `:dependent` option. However
|
2013-11-01 21:04:30 +00:00
|
|
|
if `:dependent` value is `:destroy` then the `:delete_all` deletion
|
2013-05-13 21:10:23 +00:00
|
|
|
strategy for that collection will be applied.
|
|
|
|
|
|
|
|
User can also force a deletion strategy by passing parameter to
|
2013-11-01 21:04:30 +00:00
|
|
|
`delete_all`. For example you can do `@post.comments.delete_all(:nullify)`.
|
2013-05-13 21:10:23 +00:00
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-02 01:38:12 +00:00
|
|
|
* Calling default_scope without a proc will now raise `ArgumentError`.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-02 02:06:34 +00:00
|
|
|
* Removed deprecated method `type_cast_code` from Column.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-01 19:37:02 +00:00
|
|
|
* Removed deprecated options `delete_sql` and `insert_sql` from HABTM
|
|
|
|
association.
|
|
|
|
|
|
|
|
Removed deprecated options `finder_sql` and `counter_sql` from
|
|
|
|
collection association.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-07-01 20:44:24 +00:00
|
|
|
* Remove deprecated `ActiveRecord::Base#connection` method.
|
|
|
|
Make sure to access it via the class.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-01 19:59:43 +00:00
|
|
|
* Remove deprecation warning for `auto_explain_threshold_in_seconds`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-01 20:11:20 +00:00
|
|
|
* Remove deprecated `:distinct` option from `Relation#count`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-07-01 17:43:03 +00:00
|
|
|
* Removed deprecated methods `partial_updates`, `partial_updates?` and
|
|
|
|
`partial_updates=`.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-12-05 10:33:12 +00:00
|
|
|
* Removed deprecated method `scoped`.
|
2013-07-01 11:54:42 +00:00
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-12-05 10:33:12 +00:00
|
|
|
* Removed deprecated method `default_scopes?`.
|
2013-07-01 11:29:34 +00:00
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-06-27 19:46:24 +00:00
|
|
|
* Remove implicit join references that were deprecated in 4.0.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
# before with implicit joins
|
|
|
|
Comment.where('posts.author_id' => 7)
|
|
|
|
|
|
|
|
# after
|
|
|
|
Comment.references(:posts).where('posts.author_id' => 7)
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-04-19 11:52:44 +00:00
|
|
|
* Apply default scope when joining associations. For example:
|
|
|
|
|
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
default_scope -> { where published: true }
|
|
|
|
end
|
|
|
|
|
|
|
|
class Comment
|
|
|
|
belongs_to :post
|
|
|
|
end
|
|
|
|
|
|
|
|
When calling `Comment.joins(:post)`, we expect to receive only
|
|
|
|
comments on published posts, since that is the default scope for
|
|
|
|
posts.
|
|
|
|
|
|
|
|
Before this change, the default scope from `Post` was not applied,
|
|
|
|
so we'd get comments on unpublished posts.
|
|
|
|
|
|
|
|
*Jon Leighton*
|
|
|
|
|
2013-12-05 10:33:12 +00:00
|
|
|
* Remove `activerecord-deprecated_finders` as a dependency.
|
2013-06-27 17:56:30 +00:00
|
|
|
|
|
|
|
*Łukasz Strzałkowski*
|
|
|
|
|
2013-06-25 23:58:43 +00:00
|
|
|
* Remove Oracle / Sqlserver / Firebird database tasks that were deprecated in 4.0.
|
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-06-18 09:21:52 +00:00
|
|
|
* `find_each` now returns an `Enumerator` when called without a block, so that it
|
|
|
|
can be chained with other `Enumerable` methods.
|
|
|
|
|
|
|
|
*Ben Woosley*
|
|
|
|
|
2013-06-18 10:32:01 +00:00
|
|
|
* `ActiveRecord::Result.each` now returns an `Enumerator` when called without
|
|
|
|
a block, so that it can be chained with other `Enumerable` methods.
|
|
|
|
|
|
|
|
*Ben Woosley*
|
|
|
|
|
2013-05-30 03:36:19 +00:00
|
|
|
* Flatten merged join_values before building the joins.
|
2013-06-25 08:12:10 +00:00
|
|
|
|
2013-05-30 03:36:19 +00:00
|
|
|
While joining_values special treatment is given to string values.
|
|
|
|
By flattening the array it ensures that string values are detected
|
|
|
|
as strings and not arrays.
|
|
|
|
|
|
|
|
Fixes #10669.
|
|
|
|
|
|
|
|
*Neeraj Singh and iwiznia*
|
|
|
|
|
2013-05-11 04:34:25 +00:00
|
|
|
* Do not load all child records for inverse case.
|
|
|
|
|
|
|
|
currently `post.comments.find(Comment.first.id)` would load all
|
|
|
|
comments for the given post to set the inverse association.
|
|
|
|
|
|
|
|
This has a huge performance penalty. Because if post has 100k
|
|
|
|
records and all these 100k records would be loaded in memory
|
|
|
|
even though the comment id was supplied.
|
|
|
|
|
|
|
|
Fix is to use in-memory records only if loaded? is true. Otherwise
|
|
|
|
load the records using full sql.
|
|
|
|
|
|
|
|
Fixes #10509.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-06-19 16:27:13 +00:00
|
|
|
* `inspect` on Active Record model classes does not initiate a
|
|
|
|
new connection. This means that calling `inspect`, when the
|
|
|
|
database is missing, will no longer raise an exception.
|
|
|
|
Fixes #10936.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
Author.inspect # => "Author(no database connection)"
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-19 16:28:49 +00:00
|
|
|
* Handle single quotes in PostgreSQL default column values.
|
|
|
|
Fixes #10881.
|
|
|
|
|
|
|
|
*Dylan Markow*
|
|
|
|
|
2013-06-18 08:46:33 +00:00
|
|
|
* Log the sql that is actually sent to the database.
|
|
|
|
|
|
|
|
If I have a query that produces sql
|
|
|
|
`WHERE "users"."name" = 'a b'` then in the log all the
|
|
|
|
whitespace is being squeezed. So the sql that is printed in the
|
|
|
|
log is `WHERE "users"."name" = 'a b'`.
|
|
|
|
|
|
|
|
Do not squeeze whitespace out of sql queries. Fixes #10982.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-10-15 18:04:49 +00:00
|
|
|
* Fixture setup no longer depends on `ActiveRecord::Base.configurations`.
|
2013-06-10 11:52:22 +00:00
|
|
|
This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-12 12:15:15 +00:00
|
|
|
* Fix mysql2 adapter raises the correct exception when executing a query on a
|
|
|
|
closed connection.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-13 16:46:30 +00:00
|
|
|
* Ambiguous reflections are on :through relationships are no longer supported.
|
|
|
|
For example, you need to change this:
|
|
|
|
|
2013-06-18 19:12:24 +00:00
|
|
|
class Author < ActiveRecord::Base
|
|
|
|
has_many :posts
|
2013-11-28 16:21:18 +00:00
|
|
|
has_many :taggings, through: :posts
|
2013-06-18 19:12:24 +00:00
|
|
|
end
|
2013-06-15 12:34:55 +00:00
|
|
|
|
2013-06-18 19:12:24 +00:00
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
has_one :tagging
|
|
|
|
has_many :taggings
|
|
|
|
end
|
2013-06-15 12:34:55 +00:00
|
|
|
|
2013-06-18 19:12:24 +00:00
|
|
|
class Tagging < ActiveRecord::Base
|
|
|
|
end
|
2013-06-13 16:46:30 +00:00
|
|
|
|
|
|
|
To this:
|
|
|
|
|
2013-06-18 19:12:24 +00:00
|
|
|
class Author < ActiveRecord::Base
|
|
|
|
has_many :posts
|
2013-11-28 16:21:18 +00:00
|
|
|
has_many :taggings, through: :posts, source: :tagging
|
2013-06-18 19:12:24 +00:00
|
|
|
end
|
2013-06-15 12:34:55 +00:00
|
|
|
|
2013-06-18 19:12:24 +00:00
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
has_one :tagging
|
|
|
|
has_many :taggings
|
|
|
|
end
|
2013-06-15 12:34:55 +00:00
|
|
|
|
2013-06-18 19:12:24 +00:00
|
|
|
class Tagging < ActiveRecord::Base
|
|
|
|
end
|
2013-06-13 16:46:30 +00:00
|
|
|
|
2013-06-26 03:55:28 +00:00
|
|
|
*Aaron Patterson*
|
2013-06-18 19:16:26 +00:00
|
|
|
|
2013-05-13 17:31:00 +00:00
|
|
|
* Remove column restrictions for `count`, let the database raise if the SQL is
|
2013-06-12 09:45:52 +00:00
|
|
|
invalid. The previous behavior was untested and surprising for the user.
|
2013-05-13 17:31:00 +00:00
|
|
|
Fixes #5554.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
User.select("name, username").count
|
|
|
|
# Before => SELECT count(*) FROM users
|
|
|
|
# After => ActiveRecord::StatementInvalid
|
|
|
|
|
|
|
|
# you can still use `count(:all)` to perform a query unrelated to the
|
|
|
|
# selected columns
|
|
|
|
User.select("name, username").count(:all) # => SELECT count(*) FROM users
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-08 03:59:27 +00:00
|
|
|
* Rails now automatically detects inverse associations. If you do not set the
|
|
|
|
`:inverse_of` option on the association, then Active Record will guess the
|
|
|
|
inverse association based on heuristics.
|
|
|
|
|
|
|
|
Note that automatic inverse detection only works on `has_many`, `has_one`,
|
|
|
|
and `belongs_to` associations. Extra options on the associations will
|
|
|
|
also prevent the association's inverse from being found automatically.
|
|
|
|
|
|
|
|
The automatic guessing of the inverse association uses a heuristic based
|
|
|
|
on the name of the class, so it may not work for all associations,
|
|
|
|
especially the ones with non-standard names.
|
|
|
|
|
|
|
|
You can turn off the automatic detection of inverse associations by setting
|
|
|
|
the `:inverse_of` option to `false` like so:
|
|
|
|
|
2013-06-18 19:12:24 +00:00
|
|
|
class Taggable < ActiveRecord::Base
|
|
|
|
belongs_to :tag, inverse_of: false
|
|
|
|
end
|
2013-06-08 03:59:27 +00:00
|
|
|
|
|
|
|
*John Wang*
|
|
|
|
|
2014-01-06 09:57:00 +00:00
|
|
|
* Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432.
|
2013-05-06 02:06:12 +00:00
|
|
|
|
|
|
|
*Adam Anderson*
|
|
|
|
|
2013-05-27 14:52:42 +00:00
|
|
|
* Usage of `implicit_readonly` is being removed`. Please use `readonly` method
|
|
|
|
explicitly to mark records as `readonly.
|
|
|
|
Fixes #10615.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
user = User.joins(:todos).select("users.*, todos.title as todos_title").readonly(true).first
|
|
|
|
user.todos_title = 'clean pet'
|
|
|
|
user.save! # will raise error
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-05-21 15:59:37 +00:00
|
|
|
* Fix the `:primary_key` option for `has_many` associations.
|
2014-01-14 08:19:37 +00:00
|
|
|
|
2013-05-21 15:59:37 +00:00
|
|
|
Fixes #10693.
|
|
|
|
|
|
|
|
*Yves Senn*
|
|
|
|
|
2013-06-12 09:45:52 +00:00
|
|
|
* Fix bug where tiny types are incorrectly coerced as boolean when the length is more than 1.
|
2013-05-22 17:40:32 +00:00
|
|
|
|
|
|
|
Fixes #10620.
|
|
|
|
|
2013-06-26 03:55:28 +00:00
|
|
|
*Aaron Patterson*
|
2013-05-22 17:40:32 +00:00
|
|
|
|
2013-05-18 13:52:46 +00:00
|
|
|
* Also support extensions in PostgreSQL 9.1. This feature has been supported since 9.1.
|
2013-05-07 17:45:35 +00:00
|
|
|
|
|
|
|
*kennyj*
|
|
|
|
|
2013-05-12 17:49:49 +00:00
|
|
|
* Deprecate `ConnectionAdapters::SchemaStatements#distinct`,
|
|
|
|
as it is no longer used by internals.
|
|
|
|
|
2013-06-18 19:16:26 +00:00
|
|
|
*Ben Woosley*
|
2013-05-12 17:49:49 +00:00
|
|
|
|
2013-05-12 02:51:27 +00:00
|
|
|
* Fix pending migrations error when loading schema and `ActiveRecord::Base.table_name_prefix`
|
|
|
|
is not blank.
|
2013-05-12 02:32:33 +00:00
|
|
|
|
2013-05-12 02:51:27 +00:00
|
|
|
Call `assume_migrated_upto_version` on connection to prevent it from first
|
|
|
|
being picked up in `method_missing`.
|
|
|
|
|
|
|
|
In the base class, `Migration`, `method_missing` expects the argument to be a
|
|
|
|
table name, and calls `proper_table_name` on the arguments before sending to
|
|
|
|
`connection`. If `table_name_prefix` or `table_name_suffix` is used, the schema
|
|
|
|
version changes to `prefix_version_suffix`, breaking `rake test:prepare`.
|
2013-05-12 02:32:33 +00:00
|
|
|
|
|
|
|
Fixes #10411.
|
|
|
|
|
|
|
|
*Kyle Stevens*
|
|
|
|
|
2013-05-12 02:51:27 +00:00
|
|
|
* Method `read_attribute_before_type_cast` should accept input as symbol.
|
2013-05-11 07:08:08 +00:00
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-05-06 22:31:20 +00:00
|
|
|
* Confirm a record has not already been destroyed before decrementing counter cache.
|
|
|
|
|
|
|
|
*Ben Tucker*
|
|
|
|
|
2013-05-07 01:22:43 +00:00
|
|
|
* Fixed a bug in `ActiveRecord#sanitize_sql_hash_for_conditions` in which
|
|
|
|
`self.class` is an argument to `PredicateBuilder#build_from_hash`
|
2013-05-07 17:04:11 +00:00
|
|
|
causing `PredicateBuilder` to call non-existent method
|
2013-05-07 01:22:43 +00:00
|
|
|
`Class#reflect_on_association`.
|
2013-04-26 00:20:33 +00:00
|
|
|
|
|
|
|
*Zach Ohlgren*
|
|
|
|
|
2013-05-03 04:46:18 +00:00
|
|
|
* While removing index if column option is missing then raise IrreversibleMigration exception.
|
|
|
|
|
|
|
|
Following code should raise `IrreversibleMigration`. But the code was
|
|
|
|
failing since options is an array and not a hash.
|
|
|
|
|
|
|
|
def change
|
|
|
|
change_table :users do |t|
|
|
|
|
t.remove_index [:name, :email]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Fix was to check if the options is a Hash before operating on it.
|
|
|
|
|
|
|
|
Fixes #10419.
|
|
|
|
|
|
|
|
*Neeraj Singh*
|
|
|
|
|
2013-02-26 02:06:35 +00:00
|
|
|
* Do not overwrite manually built records during one-to-one nested attribute assignment
|
|
|
|
|
|
|
|
For one-to-one nested associations, if you build the new (in-memory)
|
|
|
|
child object yourself before assignment, then the NestedAttributes
|
|
|
|
module will not overwrite it, e.g.:
|
|
|
|
|
|
|
|
class Member < ActiveRecord::Base
|
|
|
|
has_one :avatar
|
|
|
|
accepts_nested_attributes_for :avatar
|
|
|
|
|
|
|
|
def avatar
|
|
|
|
super || build_avatar(width: 200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
member = Member.new
|
|
|
|
member.avatar_attributes = {icon: 'sad'}
|
|
|
|
member.avatar.width # => 200
|
|
|
|
|
|
|
|
*Olek Janiszewski*
|
|
|
|
|
2013-05-28 12:34:47 +00:00
|
|
|
* fixes bug introduced by #3329. Now, when autosaving associations,
|
|
|
|
deletions happen before inserts and saves. This prevents a 'duplicate
|
2013-04-11 03:29:19 +00:00
|
|
|
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*
|
|
|
|
|
2013-05-01 18:33:11 +00:00
|
|
|
* 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*
|
|
|
|
|
2013-05-01 00:24:29 +00:00
|
|
|
* Mute `psql` output when running rake db:schema:load.
|
|
|
|
|
|
|
|
*Godfrey Chan*
|
|
|
|
|
2013-03-07 21:43:00 +00:00
|
|
|
* Trigger a save on `has_one association=(associate)` when the associate contents have changed.
|
|
|
|
|
2014-01-14 08:19:37 +00:00
|
|
|
Fixes #8856.
|
2013-03-07 21:43:00 +00:00
|
|
|
|
|
|
|
*Chris Thompson*
|
|
|
|
|
2013-04-30 17:21:23 +00:00
|
|
|
* Abort a rake task when missing db/structure.sql like `db:schema:load` task.
|
|
|
|
|
|
|
|
*kennyj*
|
2013-04-26 00:20:33 +00:00
|
|
|
|
2013-05-02 15:09:59 +00:00
|
|
|
* rake:db:test:prepare falls back to original environment after execution.
|
2013-04-26 00:20:33 +00:00
|
|
|
|
2013-05-02 15:09:59 +00:00
|
|
|
*Slava Markevich*
|
2013-03-23 18:09:53 +00:00
|
|
|
|
2013-04-29 16:06:45 +00:00
|
|
|
Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes.
|