Skip to content
Snippets Groups Projects
Commit f5b75a84 authored by Peter Rotich's avatar Peter Rotich
Browse files

orm: Add support for DISTINCT to SqlAggregate

parent 1a69c2ab
No related branches found
No related tags found
No related merge requests found
......@@ -612,7 +612,10 @@ class SqlAggregate extends SqlFunction {
}
function toSql($compiler, $model=false, $alias=false) {
$options = array('constraint'=>$this->constraint);
$options = array(
'constraint' => $this->constraint,
'distinct' => $this->distinct);
list($field) = $compiler->getField($this->expr, $model, $options);
return sprintf('%s(%s)%s', $this->func, $field,
$alias && $this->alias ? ' AS '.$compiler->quote($this->alias) : '');
......@@ -1373,6 +1376,10 @@ class SqlCompiler {
$field = $alias.'.'.$this->quote($field);
else
$field = $this->quote($field);
if (isset($options['distinct']) && $options['distinct'])
$field = " DISTINCT $field";
if (isset($options['model']) && $options['model'])
$operator = $model;
return array($field, $operator);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment