-
-
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
Bind Param types ignored for non-scalar property values #13058
Comments
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues |
This should not be closed as it is still an open issue. Is there any update on a resolution to this? |
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues |
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues |
Once again, this should not be closed. It is still an active issue to my knowledge. |
Thanks @ldennison I will try and get to it as soon as I can. |
Wrote unit tests for issue phalcon#13058
Added note about fixing phalcon#13058
Wrote unit tests for issue phalcon#13058 Update CHANGELOG-3.4.md Added note about fixing phalcon#13058
Wrote unit tests for issue phalcon#13058 Update CHANGELOG-3.4.md
Wrote unit tests for issue phalcon#13058 Update CHANGELOG-3.4.md Fixed an issue with unit test.
Wrote unit tests for issue #13058 Update CHANGELOG-3.4.md Fixed an issue with unit test.
This should be fixed in 3.4.2 :) |
Closing. Thanks @CameronHall |
Expected and Actual Behavior
This is a related/continuation of #2752. Consider these two cases below.
Here we have a custom
DateTime_Custom
class that simply adds a__toString()
method for conversion (since the baseDateTime
class doesn't have that).Here we have case 1, where we set a property (i.e. DB field) to the
DateTime_Custom
object.This produces a SQL error because the field value for
datetime_field
is not bound or escaped. This is the specific SQL it produces:However, if we force a cast during the assignment of the property, like this:
Then, the value is properly bound and the SQL produced is:
But, why do we need to force a cast to string during assignment of the property? The whole point is for us to be able to interact with the property as a DateTime_Custom object, and then Phalcon converts it to a string (by the
DateTime_Custom->__toString()
method) when it actually prepares SQL for saving. By the first case above, Phalcon is clearly aware of the__toString()
method because it's giving the proper date value. The problem is that Phalcon is not properly understanding that it's a string and binding it as such.The bind param type within the
modelsMetadata->getBindTypes()
method is listed asBIND_PARAM_STR
for thedatetime_field
property. So, why doesn't Phalcon know to bind as a string on model save, same as always? That seems like a bug or piece of missing functionality to me. If I'm going wrong somewhere with this logic, please let me know your thoughts.Details
The text was updated successfully, but these errors were encountered: