Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Zend\Db\Sql\Predicate\Predicate: $nextPredicateCombineOperator + addPredicate() not working #6800

Closed
Pittiplatsch opened this issue Oct 24, 2014 · 2 comments
Assignees
Labels
Milestone

Comments

@Pittiplatsch
Copy link

Zend\Db\Sql\Predicate\PredicateSet::addPredicate() doesn't consider $this->nextPredicateCombineOrder, and it actually can't do so because $this->nextPredicateCombineOrder is defined in Zend\Db\Sql\Predicate\Predicate which derives from Zend\Db\Sql\Predicate\PredicateSet.

I created two test cases: #6799
Test case 50 succeeds implicitly because the default combine order which is used by Zend\Db\Sql\Predicate\PredicateSet::addPredicate() instead of intended Zend\Db\Sql\Predicate\Predicate::nextPredicateCombineOrder is AND.
Test case 51 however fails, unveiling the observed (mis-) behaviour.

@Pittiplatsch
Copy link
Author

I have implemented a new method Zend\Db\Sql\Predicate\Predicate::predicate which allows usage of generic predicates fluently when building queries the ->and / ->or way.

The obvious way of extending Zend\Db\Sql\Predicate\PredicateSet::addPredicate() or copying it to Zend\Db\Sql\Predicate\Predicate::addPredicate() which adds logic to utilize Zend\Db\Sql\Predicate\Predicate::nextPredicateCombineOrder doesn't make sense because within Predicate we precisely DON'T want to specify $combination but use Predicate::nextPredicateCombineOrder instead.
Doing so would collide with current usage of addPredicate, e.g. in Zend\Db\Sql\Select::where(), where Zend\Db\Sql\Predicate\PredicateSet::addPredicates() (which in turn calls addPredicate()) is called with Zend\Db\Sql\Select::where()'s default for $combination.

However, I am not entirely happy with the method's name predicate. Alternatives like generic or raw feel even worse. Proposals are welcome ;-)

@weierophinney
Copy link
Member

Fixed with #6799

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants