diff --git a/include/class.orm.php b/include/class.orm.php
index de3434cc1cedc228406905811676651924e4e38e..c3b8153186487ac4bd9d6bd490d574a286d7e6b3 100644
--- a/include/class.orm.php
+++ b/include/class.orm.php
@@ -803,12 +803,12 @@ class QuerySet implements IteratorAggregate, ArrayAccess, Serializable {
         if (!is_array($annotations))
             $annotations = func_get_args();
         foreach ($annotations as $name=>$A) {
-            if ($A instanceof Aggregate) {
+            if ($A instanceof SqlAggregate) {
                 if (is_int($name))
                     $name = $A->getFieldName();
                 $A->setAlias($name);
-                $this->annotations[$name] = $A;
             }
+            $this->annotations[$name] = $A;
         }
         return $this;
     }