Search code examples
phpsqlpropel

Chaining filterByXXX bug?


I have the following code:

$somethingArray = array( 3, 4, 5 );

$myObjects = MyObjQuery::create()
  ->filterBySomething( $somethingArray )
  ->filterById( array( 'min' => $minMyObjID ) )
  ->orderByObjTimestamp('DESC')
  ->find();

Which according to the Propel documentation, should result in a SQL command that ends up checking if the 'something' is IN the somethingArray array, and that the id is > $minMyObjID. But instead, the id is IN instead of >.

If I do the following instead:

$myObjects = MyObjQuery::create()
  ->filterBySomething( $somethingArray )
  ->where( 'id > ' . $minMyObjID )
  ->orderByObjTimestamp('DESC')
  ->find();

The resulting SQL is what I would expect. Is this a Propel bug, or am I misunderstanding the documentation when it comes to filterByXXX parameters?


Solution

  • I found an issue on the Propel bug tracker: https://github.com/propelorm/Propel/issues/327

    This is an official bug. No patch at the moment.

    A work around is to use second parameter of filterById: comparison:

    ->filterById($minMyObjID, '>')
    

    Which leads to the same work around you find, but in a more Propel way.