| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|\
| |
| |
| |
| |
| | |
swoker/activerecord_fix_aggregate_methods_with_select
Activerecord fix aggregate methods with select
|
| | |
|
|\ \
| |/
|/|
| |
| |
| |
| | |
Fix insertion of records for hmt association with scope
Conflicts:
activerecord/CHANGELOG.md
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | | |
Renamed private methods _create_record and _update_record
|
| | |
| | |
| | |
| | |
| | |
| | | |
This is to ensure that they are not accidentally called by the app code.
They are renamed to _create_record and _update_record respectively.
Closes #11645
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It was causing error when using `with_options` passing a lambda as its
last argument.
class User < ActiveRecord::Base
with_options dependent: :destroy do |assoc|
assoc.has_many :profiles, -> { where(active: true) }
end
end
It was happening because the `option_merger` was taking the last
argument and checking if it was a Hash. This breaks the HasMany usage,
because its last argument can be a Hash or a Proc.
As the behavior described in this test:
https://github.com/rails/rails/blob/master/activesupport/test/option_merger_test.rb#L69
the method will only accept the lambda, this way it will keep the expected behavior. See 9eaa0a34
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
eileencodes/fix_delete_all_to_not_use_IN_statement
Fix delete all to not produce sql in statement
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
delete_all sql if an association is not loaded should behave
the same as if the association is loaded. This test ensures
the SQL statements are exactly the same.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The new method relies on AR::Associations::Association knowing about both reflection and a model class.
AR::Base#association now raises a descriptive error when trying to access non-existent associations. Previously it would blow up with a confusing NoMethodError: undefined method `association_class' for nil:NilClass.
|
|/ / /
| | |
| | |
| | | |
Defer to Association#klass instead of having a custom/duplicate code.
|
|\ \ \
| | | |
| | | | |
Pass a base relation to build_default_scope when joining
|
| | | |
| | | |
| | | |
| | | |
| | | | |
This allows the default scope to be built using the current table alias.
Resolves #12770
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
Still touch associations when theres no timestamp
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Prior to Rails 4.0.4 when touching a object which doesn't have timestamp
attributes (updated_at / updated_on) rails would still touch all
associations. After 73ba2c14cd7d7dfb2d132b18c47ade995401736f it updates
associations but rollsback because `touch` would return nil since
there's no timestamp attribute
|
| | | | |
| | | | |
| | | | |
| | | | | |
Backport test from #14410
|
| | | | |
| | | | |
| | | | |
| | | | | |
Closes #14406.
|
|\ \ \ \ \
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
tgxworld/use_teardown_helper_method_in_activerecord
Use teardown helper method.
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Follow-Up to https://github.com/rails/rails/pull/14348
Ensure that SQLCounter.clear_log is called after each test.
This is a step to prevent side effects when running tests. This will allow us to run them in random order.
|
|/ / / /
| | | |
| | | |
| | | | |
Fixes #14383.
|
| | | |
| | | |
| | | |
| | | | |
please pass the id of the AR object by calling `.id` on the model first.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When replacing a has_many association with the same one, there is no
need to do a round-trip to the db to create/and drop a new transaction.
[fixes #14220]
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This is a partial revert of 22b3481ba2aa55fad1f9a5db94072312b345fb55.
The current implementation of `references_eager_loaded_tables?` needs to know
every table involved in the query. With the current API this is not possible
without SQL parsing.
While a2dab46cae35a06fd5c5500037177492a047c252 deprecated SQL parsing for `includes`.
It did not issue deprecation warnings when String joins are involved. This resulted
in a breaking change after the deprecated behavior was removed (22b3481ba2aa55fad1f9a5db94072312b345fb55).
We will need to rethink the usage of `includes`, `preload` and `eager_load` but for now,
this brings back the old *working* behavior.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`before_add` callbacks are fired before the record is saved on
`has_and_belongs_to_many` assocations *and* on `has_many :through`
associations. Before this change, `before_add` callbacks would be fired
before the record was saved on `has_and_belongs_to_many` associations, but
*not* on `has_many :through` associations.
Fixes #14144
|
| | |
| | |
| | |
| | | |
This reverts commit 5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.
|
|/ /
| |
| |
| | |
[related #14116]
|
| | |
|
| |
| |
| |
| |
| | |
AssociationScope no longer maintains state, so we're safe to keep a
singleton and save on GC time
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
Dangerous association names conflicts include instance or class
methods already defined by `ActiveRecord::Base`.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This commit fixes two regressions introduced in cafe31a078 where
newly created finder methods #second, #third, #forth, and #fifth
caused a NoMethodError error on reload associations and where we
were pulling the wrong element out of cached associations.
Examples:
some_book.authors.reload.second
# Before
# => NoMethodError: undefined method 'first' for nil:NilClass
# After
# => #<Author id: 2, name: "Sally Second", ...>
some_book.first.authors.first
some_book.first.authors.second
# Before
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 1, name: "Freddy First", ...>
# After
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 2, name: "Sally Second", ...>
Fixes #13783.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
has_many definitions with "name" as singular and as plural e.g.
has_many :welcome_posts_with_comment
has_many :welcome_posts_with_comments
Ruby mentions it with:
lib/active_record/associations/builder/collection_association.rb:65:
warning: method redefined; discarding old welcome_posts_with_comment_ids
lib/active_record/associations/builder/collection_association.rb:65:
warning: previous definition of welcome_posts_with_comment_ids was here
lib/active_record/associations/builder/collection_association.rb:75:
warning: method redefined; discarding old welcome_posts_with_comment_ids=
lib/active_record/associations/builder/collection_association.rb:75:
warning: previous definition of welcome_posts_with_comment_ids= was here
|
|\ \
| | |
| | |
| | |
| | | |
derikson/collection_proxy_select_with_multiple_args
Change CollectionProxy#select to take the same arguments as ActiveRecord::select
|
| | |
| | |
| | |
| | |
| | |
| | | |
arguments.
This makes the arguments the same as ActiveRecord::QueryMethods::select.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
a8 introduced a regression in includes/preloades
by calling `read_attribute` on an association when preloading takes places, instead of using loaded records in `association.target`.
tl;dr
Records are not made properly available via `read_attribute` when preloding in simultaneous,
but value of `@loaded` is already set true, and records concatenated in `association.target` on an association object.
When `@loaded` is true we return an object of `AlreadyLoaded` in preload_for. In `AlreadyLoaded` to return preloaded
records we make wrong use of `read_attribute`, instead of `target` records.
The regression is fixed by making use of the loaded records in `association.target` when the preloading takes place.
Fixes #13437
|
| | |
| | |
| | |
| | | |
Fixes: #13445
|
| | |
| | |
| | |
| | |
| | |
| | | |
Change most tests to make use of assert_raise returning the raised
exception rather than relying on a combination of flunk + rescue to
check for exception types/messages.
|