Propel 2.0 Criteria Ideas

The following is a list of things Criteria (and !BasePeer::createSelectSQL()) should be able to do in Propel 2.0:

  • Advanced JOIN support, including LEFT JOIN, RIGHT JOIN etc
  • Proper grouping of WHERE statements when joining (i.e. all other conditions are wrapped into braces), this currently doesn't always work
  • Field-to-field comparisons (WHERE table.foo = table.bar)
  • Aggregate function support
  • ORDER BY RAND() (dunno if all RDBMs support this, check!) (ORDER BY random() in PostgreSQL and SQLite, ORDER BY RAND() in MySQL, ORDER BY NEWID() in SQL Server. Apparently not that easy to do in Oracle, tho (needs additional select columns etc, more work, but far from impossible)).
  • Easier support for multiple conditions on one column (so Criterions don't have to be used)
  • Fix the handling of Criterions (they currently may overwrite each other)

I think field-to-field-comparisons, be achieved relatively easily. Criteria::add() would accept another argument where one can pass in Criteria::FIELD or Criteria::VALUE, defaulting to VALUE. FIELD will not "escape" a string, making it possible to do stuff like

$c->add(FooPeer::BAR, FooPeer::BAZ, Criteria::GREATER_THAN, Criteria::FIELD);