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

Add support for empty values set with IN predicate #223

Merged
merged 3 commits into from Feb 28, 2017

Conversation

Projects
None yet
2 participants
@nanawel
Contributor

nanawel commented Feb 27, 2017

(Original PR #196)

It should be possible to construct a IN predicate with empty values set.

$select->where('mycolumn IN ?', []);

Of course this code will most likely never be written as is but the content of the set can instead be the result of a calculation.

It's not possible with the current code because of the if ($valueSet) in the constructor and the missing default value in the field definition above, which leads to the following error on line 122 when predicate is built:

Invalid argument supplied for foreach()

Empty sets are supported by some DBMS (SQLite for example) and in that case are the equivalent of WHERE FALSE (since no result can be part of an empty set...).

Show outdated Hide outdated src/Sql/Predicate/In.php Outdated
@nanawel

This comment has been minimized.

Show comment
Hide comment
@nanawel

nanawel Feb 28, 2017

Contributor

@ezimuel Not with versions of PHP < 5.6. My code is here to avoid a warning with those older versions of PHP.
Refer to History section at https://secure.php.net/manual/fr/function.array-fill.php

Contributor

nanawel commented Feb 28, 2017

@ezimuel Not with versions of PHP < 5.6. My code is here to avoid a warning with those older versions of PHP.
Refer to History section at https://secure.php.net/manual/fr/function.array-fill.php

@ezimuel

This comment has been minimized.

Show comment
Hide comment
@ezimuel

ezimuel Feb 28, 2017

Member

@nanawel ok, I see the point. Makes no sense to add a check for PHP < 5.6. The code looks good to me. I'm going to merge in a while. Thanks for your contribution!

Member

ezimuel commented Feb 28, 2017

@nanawel ok, I see the point. Makes no sense to add a check for PHP < 5.6. The code looks good to me. I'm going to merge in a while. Thanks for your contribution!

@nanawel

This comment has been minimized.

Show comment
Hide comment
@nanawel

nanawel Feb 28, 2017

Contributor

And thanks to you!

Contributor

nanawel commented Feb 28, 2017

And thanks to you!

@ezimuel ezimuel added the enhancement label Feb 28, 2017

@ezimuel ezimuel merged commit 699a7cf into zendframework:develop Feb 28, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.007%) to 45.654%
Details

@nanawel nanawel deleted the nanawel:in-predicate-empty-set branch Dec 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment