Skip to content

ActiveRecord#strict_loading! should return boolean instead of current mode set.#41839

Merged
eileencodes merged 1 commit intorails:mainfrom
abhaynikam:fix-return-type-for-strict-loading
Apr 15, 2021
Merged

ActiveRecord#strict_loading! should return boolean instead of current mode set.#41839
eileencodes merged 1 commit intorails:mainfrom
abhaynikam:fix-return-type-for-strict-loading

Conversation

@abhaynikam
Copy link
Contributor

@abhaynikam abhaynikam commented Apr 5, 2021

The return type was changed in the PR #41704 after addition of mode
option. The current documentation is misleading since
documentation propose strict_loading! would return boolean whereas
it returns the current mode set.

I came across this issue while debugging: #41827 and thought
this should be brought to the attention.

PR fixes the issue and would always return boolean based on
strict_loading is enabled or disabled.

user.strict_loading! # => true
user.strict_loading!(false) # => false
user.strict_loading!(mode: :n_plus_one_only) # => true

@eileencodes
Copy link
Member

cc/ @dinahshi can you review this?

@abhaynikam
Copy link
Contributor Author

Ping cc/ @eileencodes @dinahshi

@kamipo
Copy link
Member

kamipo commented Apr 15, 2021

The return type was changed in the PR rails#41704 after addition of mode
option. The current documentation is misleading since
documentation puropose strict_loading! would return boolean whereas
it returns the current mode set.

I can across this issue while debugging issue: rails#41827 and thought
this should be brought to the attention.

PR fixes the issue and would always return boolean based on
strict_loading is enabled or disabled.

```
user.strict_loading! # => true
user.strict_loading!(false) # => false
user.strict_loading!(mode: :n_plus_one_only) # => true
```
@abhaynikam
Copy link
Contributor Author

@kamipo Added test cases. CI failure doesn't look relevant and at the moment the mysql2 setup on dev environment is not working so it is hard to debug the failing spec.

@yahonda
Copy link
Member

yahonda commented Apr 15, 2021

I can say this failure against mysql2 adapter is not relevant to this pull request. Refer #41948

@eileencodes eileencodes merged commit 80a2322 into rails:main Apr 15, 2021
@abhaynikam abhaynikam deleted the fix-return-type-for-strict-loading branch May 2, 2021 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants