-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Magic getters for relationships throws exception when there is no relation in 4.0 #14460
Comments
Can you check what happens if you add |
You mean by adding
to model BTW: I'm logging the database requests and I can see, that Phalcon tries to query database for customer |
@wurst-hans, this has just been fixed in #14444 |
Looks good. No exception is thrown and I get |
I'll take a look at that soon.
It will be included in the following 4.0.0-rc.2 release in the next few weeks. |
@wurst-hans Can you open a new issue for the suggested improvement (good catch!)? Don't want to log this in the same issue. Closing this one as duplicate. |
My projects are running on Phalcon 3.4. There I'm using many model relationships like
which works fine in Phalcon 3.4, so I can use it like
At the moment, I'm trying to migrate all projects to Phalcon 4.0.0.-rc.1-783 but when executing above code, I get an error
I found out that
getCustomer()
fails and throws exception ifcustomerId
isNULL
in modelRequests
. In Phalcon 3.4 I get afalse
as result, but 4.0 throws an exception.Getting
false
allows to initialize a new object, when there is no other already. For this I can modify the code toThere are hundreds of lines of code in my projects which have to be altered then to prevent this exception in Phalcon 4.0. Is there a workaround or is it planned to add 3.4 behavior again?
IMHO: It's not correct to not add magic getters when column used for relationship is
NULL
. The expected behavior (like when callingfindFirst()
without result) is gettingfalse
or an object.Forgot to mention, that I have tried it with lowercase alias already without success. Even with Vokuro this happens.
The text was updated successfully, but these errors were encountered: