little fix
This commit is contained in:
parent
0b8d297cb9
commit
ddb45098c0
@ -215,10 +215,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
|
|||||||
if(method_exists($this->conn->expression, $name)) {
|
if(method_exists($this->conn->expression, $name)) {
|
||||||
|
|
||||||
$argStr = substr($func, ($pos + 1), -1);
|
$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 = '';
|
$distinct = '';
|
||||||
if(count($e2) > 1) {
|
if(count($e2) > 1) {
|
||||||
@ -299,8 +307,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
|
|||||||
|
|
||||||
$sqlAlias = $tableAlias . '__' . count($this->aggregateMap);
|
$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->aggregateMap[$alias] = $sqlAlias;
|
||||||
$this->neededTables[] = $tableAlias;
|
$this->neededTables[] = $tableAlias;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,6 @@ class Doctrine_Query_Orderby_TestCase extends Doctrine_UnitTestCase
|
|||||||
->from('User u')
|
->from('User u')
|
||||||
->orderby('rand DESC');
|
->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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user