| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| |
| | |
To perform a sum calculation over the array of elements, use to_a.sum(&block).
Please check the discussion in f9cb645dfcb5cc89f59d2f8b58a019486c828c73
for more context.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit f9cb645dfcb5cc89f59d2f8b58a019486c828c73.
Conflicts:
activerecord/CHANGELOG.md
Revert "Allow blocks for count with ActiveRecord::Relation. Document and test that sum allows blocks"
This reverts commit 9cc2bf69ce296b7351dc612a8366193390a305f3.
Conflicts:
activerecord/lib/active_record/relation/calculations.rb
|
| |
|
| |
|
|\
| |
| |
| |
| |
| |
| | |
AR::Base.becomes should not change the STI type
Conflicts:
activerecord/CHANGELOG.md
|
| |
| |
| |
| | |
If you want to change the STI type too, use AR::Base.becomes! instead
|
|/ |
|
| |
|
|
|
|
| |
Closes #7551
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
This was there due historical reasons since
7dc45818dc43c163700efc9896a0f3feafa31138 to give the user the
possibility to create unique indexes passing "UNIQUE" as the third
argument
|
|
|
|
| |
Closes #8104
|
| |
|
|
|
|
| |
Public method `attributes_before_type_cast` used to return internal AR structure (ActiveRecord::AttributeMethods::Serialization::Attribute), patch fixes this. Now behaves like `read_attribute_before_type_cast` and returns unserialised values.
|
|
|
|
| |
also DATABASE_URL.
|
| |
|
|
|
|
| |
Didn't work before because it updated the model-in-memory first, so the DB query couldn't find the record.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes the following behaviour:
class Person < ActiveRecord::Base
belongs_to :company
end
# Before:
person = Person.select('id').first
person[:name] # => nil
person.name # => ActiveModel::MissingAttributeError: missing_attribute: name
person[:company_id] # => nil
person.company # => nil
# After:
person = Person.select('id').first
person[:name] # => ActiveModel::MissingAttributeError: missing_attribute: name
person.name # => ActiveModel::MissingAttributeError: missing_attribute: name
person[:company_id] # => ActiveModel::MissingAttributeError: missing_attribute: company_id
person.company # => ActiveModel::MissingAttributeError: missing_attribute: company_id
Fixes #5433.
|
| |
|
|
|
|
|
|
|
| |
The RFC indicates that username and passwords may be encoded.
http://tools.ietf.org/html/rfc2396#section-3.2.2
Found this trying to use the mysql://username:password@host:port/db and having special characters in the password which needed to be URI encoded.
|
|
|
|
|
|
|
|
|
|
| |
In the end I think the pain of implementing this seamlessly was not
worth the gain provided.
The intention was that it would allow plain ruby objects that might not
live in your main application to be subclassed and have persistence
mixed in. But I've decided that the benefit of doing that is not worth
the amount of complexity that the implementation introduced.
|
| |
|
|
|
|
| |
This reverts commit 83846838252397b3781eed165ca301e05db39293.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I think it's going to be too much pain to try to transition the
:active_record load hook from executing against Base to executing
against Model.
For example, after Model is included in Base, and modules included in
Model will no longer get added to the ancestors of Base.
So plugins which wish to be compatible with both Model and Base should
use the :active_record_model load hook which executes *before* Base gets
loaded.
In general, ActiveRecord::Model is an advanced feature at the moment and
probably most people will continue to inherit from ActiveRecord::Base
for the time being.
|
|
|
|
| |
This reflects the fact that it now impact inserts as well as updates.
|
| |
|
|
|
|
|
|
|
| |
This is similar to #first_or_create, but slightly different and a nicer
API. See the CHANGELOG/docs in the commit.
Fixes #7853
|
|
|
|
| |
Would incorrectly add duplicated errors when the association was blank. Bug introduced in 1fab518c6a75dac5773654646eb724a59741bc13.
|
|\
| |
| | |
Dup'ed ActiveRecord objects may not share the errors object
|
| |
| |
| |
| | |
dup'ed object (call ActiveModel::Validations#initialize_dup). Closes #7291
|
| | |
|
| | |
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Patches `CollectionAssociation#count` to return 0 without querying
if the parent record is new. Consider the following code:
class Account
has_many :dossiers
end
class Dossier
belongs_to :account
end
a = Account.new
a.dossiers.build
# before patch
a.dossiers.count
# SELECT COUNT(*) FROM "dossiers" WHERE "dossiers"."account_id" IS NULL
# => 0
# after
a.dosiers.count # fires without sql query
# => 0
Fixes #1856.
|
|
|
|
|
| |
The counter column name in the intermediate model need to be access
via the through reflection.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
When inserting new records, only the fields which have been changed
from the defaults will actually be included in the INSERT statement.
The other fields will be populated by the database.
This is more efficient, and also means that it will be safe to
remove database columns without getting subsequent errors in running
app processes (so long as the code in those processes doesn't
contain any references to the removed column).
|
| |
|
| |
|
|
|
|
|
|
|
| |
This reverts commit 761bc751d31c22e2c2fdae2b4cdd435b68b6d783.
This commit wasn't fixing any issue just using the same table for
different models with different primary keys.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If your database supports setting the isolation level for a transaction,
you can set it like so:
Post.transaction(isolation: :serializable) do
# ...
end
Valid isolation levels are:
* `:read_uncommitted`
* `:read_committed`
* `:repeatable_read`
* `:serializable`
You should consult the documentation for your database to understand the
semantics of these different levels:
* http://www.postgresql.org/docs/9.1/static/transaction-iso.html
* https://dev.mysql.com/doc/refman/5.0/en/set-transaction.html
An `ActiveRecord::TransactionIsolationError` will be raised if:
* The adapter does not support setting the isolation level
* You are joining an existing open transaction
* You are creating a nested (savepoint) transaction
The mysql, mysql2 and postgresql adapters support setting the
transaction isolation level. However, support is disabled for mysql
versions below 5, because they are affected by a bug
(http://bugs.mysql.com/bug.php?id=39170) which means the isolation level
gets persisted outside the transaction.
|
| |
|
| |
|