-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix pg boolean conversion #625
Fix pg boolean conversion #625
Conversation
This branch needs to be rebased as it conflicts with master (and changes shpoould probably be squashed a bit) |
@lucasvanlierop thanks for taking care of this. Maybe I can catch you during the conference and we can discuss the PR together :-) |
@stof, PR is now up to date with master, I will squash the whole thing when it's finished. @Ocramius, yes good idea, currently I'm at the point where I think boolean conversion deserves it's own class instead of having lots of extra methods in de platform class. But I don't know if you like that idea? Maybe we can use part of the lunch break to discuss it? |
* | ||
* @param mixed $item | ||
* | ||
* @return bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool|null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* | ||
* @param mixed $item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed, more precise types here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I would like to do it but not possible.
@davividal and @birko I've merged both your PR's (#564 and #527) into one new PR handling both the conversion from Postgresql database boolean values to php and vice versa. Please check if it still is what you meant it to be. I'm just here to help out with longstanding open PR's. @deeky666, Would you review this as you commented on the original PR's and also suggested part code @davividal has contributed. |
At the first glance this PR looks good so far. Something that we didn't talk about here is possible performance implications. I talked about this issue with @beberlei some time ago and he wasn't happy with all those callbacks. But I don't know really know if that has any impact on performance. |
@deeky666, thanks for taking a look. Well to be honest the conversion feels a bit over engineered to me but I tried to keep the focus on merging complementary solutions (and some cleaning up) and so I kept the logic more or less like it was. |
The original implementation had a lot of code duplication and was rather hard to read and understand. Thus I proposed a more "simplified" solution with smaller methods removing the code duplication but I see and understand that those callbacks are rather heavy here. TBH I don't mind which way to go :) |
Looks fine for me. I don't know how to test performance of the callback implementation, sorry. |
Hmm for me probably ok. If I am looking correctly |
@lucasvanlierop can you please remove lucasvanlierop/dbal@15d876f ? Please rebase instead. |
Default Boolean conversion behaviour
added postgresql literals to Boolean conversion
Changed to call platform specific Boolean conversion
added postgresql platform conversion test
fixed bug when $item was set as bool true value added 'off' literal
added literals off and on to the testcase
Changes after Ocramius comments
fixed parameter order in conditions
Description fix
This problem still continues in PHP 5.6. I think it needs more specific test. See #632 |
Probably related to #714 |
Possibly caused by https://bugs.php.net/bug.php?id=68351 - which I've just fixed (sorry I haven't read the full thread here ;) ) |
@mbeccati this reads promising. Does it also apply to |
@deeky666 yes, that's precisely what the fix is for. The bug existed in previous versions as well, but it was probably less likely to trigger it. |
@mbeccati awesome! Thanks a lot for taking care of that issue. It has been causing us bad headaches for some time now... |
private function convertSingleBooleanValue($value, $callback) | ||
{ | ||
if (null === $value) { | ||
return $callback(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use call_user_func
to support all callables on PHP 5.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, given it is a private method, it may not be needed though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe type-hint Closure
?
@mbeccati The |
@Ocramius @deeky666 For reference, the PHP bug I fixed was there since https://bugs.php.net/bug.php?id=62593 was fixed - i.e. 5.4.9+ / 5.3.19+. I'm not even sure what was the behaviour before that. |
@Ocramius I don't think we should:
|
Because of unforseen consequences there ("wtf" moments for pgsql users, mysql is fine). Anyway, users are still free to upgrade, and I agree with you on the users that are not affected by the bug. I guess the only required change is a travis upgrade of PHP 5.6 (once available) |
We could just document this incompatibility somewhere. Otherwise the only solution I see is to make PDO_PGSQL not use emulated prepares for those versions to stay compatible. But that would also require adjusting the PDO implementation DBAL wise.... |
Just to confirm that upgrading PHP from Also I agree with @deeky666 that it should be documented somewhere as known bugs. |
I'd say let's wait for travis to go for 5.6.4, see the build result and then add a section in the documentation. Not going too complicated here, we cannot deal with everything.... |
Hello, |
@Vincent-Simonin what is your php version? |
@edigu v5.5.22 |
Merge of complementary PR's #527 and #564 + some fixes. Contributing it as an result of the (extended) phpconference.nl 2014 hackathon.