| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
as value
|
|
|
|
|
|
|
| |
The error message that we give today makes this error difficult to debug
if you receive it. I have no clue why we're printing the object ID of
the class (the commit doesn't give context), but I've left it as it was
deliberate.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When looking for mutation, we compare the serialized version of the
value to the before_type_cast form. `Type::Serialized` was breaking this
contract by passing the already serialized attribute to the subtype's
mutation detection. This never manifested previously, as all mutable
subtypes either didn't do anything in their `serialize` method, or had a
way to detect double serialization (e.g. `is_a?(String)`). However, now
that JSON types can handle string primitives, we need to avoid double
serialization.
Fixes #24993.
|
|\
| |
| | |
Define ActiveRecord::Attribute::Null#type_cast
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Using ActiveRecord::Base.attribute to declare an attribute with a default value on a model where the attribute is not backed by the database would raise a NotImplementedError when model.save is called.
The error originates from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L84.
This is called from https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L46 on an ActiveRecord::Attribute::Null object.
This commit corrects the behavior by implementing ActiveRecord::Attribute::Null#type_cast.
With ActiveRecord::Attribute::Null#type_cast defined, ActiveRecord::Attribute::Null#value (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L173..L175) can be replaced with its super method (https://github.com/rails/rails/blob/59d252196b36f6afaafd231756d69ea21537cf5d/activerecord/lib/active_record/attribute.rb#L36..L40).
fixes #24979
|
|/
|
|
|
|
| |
When calling remove_connection in a subclass, that should not fallback
to the parent, otherwise it will remove the parent connection from the
handler.
|
|
|
|
|
|
|
|
| |
We cannot cache the connection_specification_name when it doesnt
exist. Thats because the parent value could change, and we should keep
failling back to the parent. If we cache that in a children as an ivar,
we would not fallback anymore in the next call, so the children would
not get the new parent spec_name.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
remove_connection
When calling `remove_connection` on a model, we delete the pool so we also
need to reset the `connection_specification_name` so it will fallback to
the parent.
This was the current behavior before rails 5, which will fallback to the
parent connection pool.
[fixes #24959]
Special thanks to @jrafanie for working with me on this fix.
|
| |
|
|\
| |
| | |
Refactor connection handler
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
ConnectionHandler will not have any knowlodge of AR models now, it will
only know about the specs.
Like that we can decouple the two, and allow the same model to use more
than one connection.
Historically, folks used to create abstract AR classes on the fly in
order to have multiple connections for the same model, and override the
connection methods.
With this, now we can override the `specificiation_id` method in the
model, to return a key, that will be used to find the connection_pool
from the handler.
|
|\ \
| | |
| | | |
Fix failures due to transactions
|
| |/
| |
| |
| |
| |
| |
| |
| | |
test_migrate_clears_schema_cache_afterward test.
Disable transactions for this test.
Fixes #24391
|
|/
|
|
|
|
|
|
|
|
|
|
| |
In 5.0 we use bind parameters for limit and offset, while in 4.2 we used
the values directly. The code as it was written assumed that limit and
offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a
different syntax, where the offset is stated before the limit. We
delegate this behavior to the connection adapter so that these adapters
are able to determine how the bind parameters are flattened based on
what order their specification has the various clauses appear.
Fixes #24775
|
|
|
|
| |
[ci skip]
|
|
|
|
| |
Fix failing tests
|
|
|
|
|
|
|
|
|
|
| |
Unlike `one?` and `none?`, `empty?` has interactions with methods
outside of enumerable. It also doesn't fit in the same vein.
`Topic.any?` makes sense. `Topic.empty?` does not, as `Topic` is not a
container.
Fixes #24808
Close #24812
|
|\
| |
| |
| |
| | |
Fix counter_cache double increment bug
Close #24183
|
| | |
|
| |
| |
| |
| |
| | |
Rails should not be explicity mentioned within Active Record, since
railties and the Rails ecosystem is not required for use.
|
| |
| |
| |
| | |
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
|
| |
| |
| |
| |
| |
| | |
Refactor of #22911.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
|
| |
| |
| |
| |
| |
| | |
Follow up of 1683410.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
|
|/ |
|
|
|
|
|
|
|
| |
in the case of sqlite.
Others adapters need to perform a check for validity.
Add coverage for mysql2 db type validation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Example:
create_table :users do |t|
t.string :name
t.index 'lower(name) varchar_pattern_ops'
end
Fixes #19090.
Fixes #21765.
Fixes #21819.
Fixes #24359.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
|
|
|
|
|
|
| |
There is no need to fetch all table indexes in remove_index if name is specified. If name is wrong, then StatementInvalid will be raised.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
|
|
|
|
|
|
|
|
|
| |
Make sure we handle explicitly passed nil's to lock_version as well.
An explicitly passed nil value is now converted to 0 on LockingType,
so that we don't end up with ActiveRecord::StaleObjectError in update record
optimistic locking
Fixes #24695
|
|\
| |
| |
| | |
Gracefully fallback on version migrations for sqlite < 3.7.11
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
78 changed INSERT INTO versions to run in 1 single query.
This breaks for sqlite versions < 3.7.11, which is especially the case on Ubuntu 12.04 LTS, that has SQLite version 3.7.9 as default.
So we check for support for multi insert, before performing single query inserts, else fallback to older version of running multiple queries.
[Vipul A M & Yasuo Honda]
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
When the query cache completes, if Active Record is still inside of a
transaction, it is because the transaction is meant to be left open
above this unit of work (such as transactional fixtures in tests). There
were several tests around the behavior of "tests" that were invalid, as
tests are not run through the executor. They have been changed to
reflect the new behavior, which is closer to what actually occurs in
Rails tests.
Fixes #23989
Fixes #24491
Close #24500
|
|\
| |
| | |
create_join_table should work with uuid
|
| | |
|
| |
| |
| |
| |
| | |
If the adapter supports indexes in create table, it generates SQL
in one query.
|
| | |
|
| |
| |
| |
| | |
comments.
|
| | |
|
|\ \
| | |
| | |
| | |
| | |
| | | |
prathamesh-sonpatki/add-test-for-warn-on-records-fetched-greater-than
Add missing test case for record_fetched_greater_than config
|
| | |
| | |
| | |
| | | |
- The negative scenario test case was missing earlier.
|
|\ \ \
| | | |
| | | |
| | | | |
Avoid a string value truncation in uniqueness validation
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
In MySQL, PostgreSQL, Oracle and SQLServer, a value over the limit
cannot be inserted or updated (See #23522).
In SQLite3, a value is inserted or updated regardless of the limit.
We should avoid a string value truncation in uniqueness validation.
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
Add `ActiveRecord::ValueTooLong` exception class
|
| | | | | |
|