Skip to content

Commit

Permalink
keep Recess from prepending table name to order by clause when doing …
Browse files Browse the repository at this point in the history
…something like $model->all()->orderBy('rand()')

Right now only works right for functions with no column name arguments, which is probably only rand().
Full implementation would parse out column names in function args and handle prepending on them.
But it might be ok to let people do their own darn prepending in that case.

Signed-off-by: Kris Jordan <krisjordan@gmail.com>(cherry picked from commit f326e62)
  • Loading branch information
midnightmonster authored and KrisJordan committed Apr 27, 2009
1 parent 53e776d commit 293a6c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion recess/recess/database/sql/SqlBuilder.class.php
Expand Up @@ -443,7 +443,7 @@ public function orderBy($clause) {
$name = $clause;
}

if(isset($this->table) && strpos($clause,'.') === false && !array_key_exists($name, $this->selectAs)) {
if(isset($this->table) && strpos($clause,'.') === false && strpos($name,'(') === false && !array_key_exists($name, $this->selectAs)) {
$this->orderBy[] = $this->tableAsPrefix() . '.' . $clause;
} else {
$this->orderBy[] = $clause;
Expand Down

0 comments on commit 293a6c3

Please sign in to comment.