Commit Graph

10 Commits

Author SHA1 Message Date
Rafael Mendonça França 2dd81877a4
Fix has_many_inversing with touch: true on a belongs_to association with inverse
`has_many_inversing` adds records to a has_many association. It does so
with destroyed records, too. So if a child was destroyed with a `touch:
true` association on the parent *and* the parent was not loaded, it
tried to load the parent to touch it. While loading the parent it added
the child record to the parent's has_many association. The logic doing
this always set the child's parent id – even if it was correct/the same
already. But since the child is destroyed, it resulted in a
`FrozenError`.

This commit prevents doing the unnecessary setting of the identical id
and therefore fixes this error.

Fixes #40943 by not doing an unneeded attribute set.

Closes #40969.

[Markus Doits + Rafael Mendonça França]
2021-01-07 22:15:24 +00:00
Ryuta Kamizono a50eacb03c Eager loading/preloading should be worked regardless of large number of records
Since 213796f, bind params are used for IN clause if enabled prepared
statements.

Unfortunately, most adapter modules have a limitation for # of bind
params (mysql2 65535, pg 65535, sqlite3 250000). So if eager loading
large number of records at once, that query couldn't be sent to the
database.

Since eager loading/preloading queries are auto-generated by Active
Record itself, so it should be worked regardless of large number of
records like as before.

Fixes #33702.
2018-09-12 01:11:38 +09:00
Kir Shatrov 831be98f9a Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00
Matthew Draper 87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590, reversing
changes made to afb66a5a59.
2017-07-02 02:15:17 +09:30
Kir Shatrov cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Xavier Noria d22e522179 modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
Akira Matsuda baaf8cf83f More unused associations in AR test models 2013-09-10 19:50:00 +02:00
Vijay Dev ec8ef1e105 Revert "Merge branch 'master' of github.com:rails/docrails"
This reverts commit 70d6e16fba, reversing
changes made to ea4db3bc07.

Seems to be a code merge done by mistake.
2013-08-17 21:46:39 +05:30
Akira Matsuda 4dd47fb9d5 More unused associations in AR test models 2013-07-25 18:52:31 +09:00
Jeremy Kemper 43b81d01d0 move assets and models
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-18 07:27:03 +00:00
Renamed from activerecord/test/fixtures/citation.rb (Browse further)