New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The associated model became not validated #38045
Comments
Related: #38036 |
Hi @wjessop. Can you take a look on this given it is related to the PR you opened some time ago? If you can't it is fine. I'm just trying to give a contributor opportunity to contribute more. |
Is this behavior expected in Rails 6? If so, I'm going to fix my code with a custom validator. |
@hkdnet Check out #37192 to see if that fixes your issue /cc @rafaelfranca |
@rafaelfranca I'm having this problem too. For any object (A) that has a |
We ran into this problem, as well (upgrading from 5.2.3 to 5.2.4.2). As we can see in the relevant PR description (#36671), the PR aimed to fix this inconsistency: squeak.valid? # => true (squeak.mouse is not loaded/validated)
squeak.mouse.present? # invalid mouse association is loaded
squeak.valid? # => false (squeak.mouse is validated) The problem is that The PR solves the problem by changing to this behavior: squeak.valid? # => true (squeak.mouse is not loaded/validated)
squeak.mouse.present? # invalid mouse association is loaded
squeak.valid? # => true (squeak.mouse is still not validated) The inconsistency could have instead been resolved by changing to this behavior: squeak.valid? # => false (load and validate squeak.mouse)
squeak.mouse.present? # (doesn't really do anything, since squeak.mouse is loaded above)
squeak.valid? # => false (continue to validate squeak.mouse) This latter behavior is probably a little bit less performant in some cases (since it will require However, the latter behavior has the advantage of checking validations more robustly (which some applications might prefer). Our application was basically expecting this latter behavior rather than the former behavior, so #36671 broke a few of our tests and somewhat changed the behavior of our application. It's not a big problem, and we were able to make appropriate adjustments to our application to accommodate the change, but I wanted to flag that this was a bit of a breaking change for us as well and that the change isn't quite what we would have preferred. |
I argue that even though this is a regression we should not change the current behaviour:
|
After we upgraded Rails from 5.2.3 to 5.2.4, our test fails.
I guess AR's behavior was changed through #36671.
Steps to reproduce
https://gist.github.com/hkdnet/9889e283c28f5994bd38e42c12ec3364
This test passes with
5.2.3
,5.1.7
and4.2.11.1
. But it fails with5.2.4
.Expected behavior
This test passes.
Actual behavior
Fails.
System configuration
Rails version: 5.2.4
Ruby version: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
The text was updated successfully, but these errors were encountered: