Commit ddb45098 authored by zYne's avatar zYne

little fix

parent 0b8d297c
......@@ -215,10 +215,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
if(method_exists($this->conn->expression, $name)) {
$argStr = substr($func, ($pos + 1), -1);
$args = explode(',', $argStr);
$args = explode(',', $argStr);
$func = call_user_func_array(array($this->conn->expression, $name), $args);
$e2 = explode(' ', $args[0]);
if(substr($func, 0, 1) !== '(') {
$pos = strpos($func, '(');
$name = substr($func, 0, $pos);
} else {
$name = $func;
}
$e2 = explode(' ', $args[0]);
$distinct = '';
if(count($e2) > 1) {
......@@ -299,8 +307,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$sqlAlias = $tableAlias . '__' . count($this->aggregateMap);
$this->parts['select'][] = $name . '(' . $distinct . implode(', ', $arglist) . ') AS ' . $sqlAlias;
if(substr($name, 0, 1) !== '(') {
$this->parts['select'][] = $name . '(' . $distinct . implode(', ', $arglist) . ') AS ' . $sqlAlias;
} else {
$this->parts['select'][] = $name . ' AS ' . $sqlAlias;
}
$this->aggregateMap[$alias] = $sqlAlias;
$this->neededTables[] = $tableAlias;
}
......
......@@ -51,6 +51,6 @@ class Doctrine_Query_Orderby_TestCase extends Doctrine_UnitTestCase
->from('User u')
->orderby('rand DESC');
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, RANDOM() AS e__0 FROM entity e WHERE (e.type = 0) ORDER BY e__0 DESC');
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, ((RANDOM() + 2147483648) / 4294967296) AS e__0 FROM entity e WHERE (e.type = 0) ORDER BY e__0 DESC');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment