combine replaces previous conditions added by filterby #450

Merged
merged 2 commits into from Oct 22, 2012

Projects

None yet

4 participants

@hholzer

No description provided.

@travisbot

This pull request passes (merged 740d8ff into 441f969).

@willdurand
Propel member

Heya,

Could you write a unit test to prove both your fix and the bug?

@willdurand
Propel member

ping @hholzer

@hholzer

hello,

we sadly don't have any experience with unit tests yet, so it's probably for the best if we simply explain the problem a bit more, so that you can reproduce it by yourself

we have a pretty complex application with a behavior wo filters rows automatically by user credentials

our behavior adds the filter by credential method wich does something like this and it's called in preSelectQuery

$this->condition('user_type', ...);
$this->condition('credential', ...);
$this->condition('user_type2', ...);
$this->combine(array('user_type', 'credential'), 'and', 'user_type_credential');
$this->combine(array('user_type_credential', 'user_type2'), 'or');

now we have the use case that we want to filter the list a bit more wich works for filterByUsername fine ... but not for ->filterByUserType because it would be overridden by the combine.

if we would use first the combine and the filterByXXX after it would work because filterByXXX seems to use Criteria::addAnd while combine uses Criteria::add

kind regards
hholzer

@Tschebel

hello,

i can confirm the issue and i wrote a unit test wich should prove that a filterByXXX before a combine gets overriden instead of added while a filterByXXX after a combine gets correclty added.

The unit test should fail without the first commit of @hholzer and work afterwards

kind regards

@willdurand willdurand merged commit 51983e4 into propelorm:master Oct 22, 2012

1 check passed

Details default The Travis build passed
@willdurand
Propel member

Great, thank you!

@willdurand willdurand referenced this pull request in propelorm/Propel2 Oct 22, 2012
Closed

Port PR #450 from Propel 1.6 #311

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