diff --git a/draft/DB.php b/draft/DB.php
index 9bbc56801..1bb516922 100644
--- a/draft/DB.php
+++ b/draft/DB.php
@@ -28,6 +28,43 @@
  * @package     Doctrine
  */
 class Doctrine_DB2 implements Countable, IteratorAggregate {
+
+    /**
+     * A connection operation or selecting a database.
+     */
+    const CONNECT = 1;
+
+    /**
+     * Any general database query that does not fit into the other constants.
+     */
+    const QUERY = 2;
+
+    /**
+     * Adding new data to the database, such as SQL's INSERT.
+     */
+    const INSERT = 4;
+
+    /**
+     * Updating existing information in the database, such as SQL's UPDATE.
+     *
+     */
+    const UPDATE = 8;
+
+    /**
+     * An operation related to deleting data in the database,
+     * such as SQL's DELETE.
+     */
+    const DELETE = 16;
+
+    /**
+     * Retrieving information from the database, such as SQL's SELECT.
+     */
+    const SELECT = 32;
+
+    /**
+     * Transactional operation, such as start transaction, commit, or rollback.
+     */
+    const TRANSACTION = 64;
     /**
      * default DSN
      */
@@ -60,10 +97,16 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
      * @var Doctrine_DB_EventListener_Interface|Doctrine_Overloadable $listener   listener for listening events
      */
     protected $listener;
-    
-    private static $driverMap = array("oracle"     => "oci8",
-                                      "postgres"   => "pgsql",
-                                      "oci"        => "oci8");
+    /**
+     * @var integer $querySequence
+     */
+    protected $querySequence  = 0;
+
+    private static $driverMap = array('oracle'     => 'oci8',
+                                      'postgres'   => 'pgsql',
+                                      'oci'        => 'oci8',
+                                      'sqlite2'    => 'sqlite',
+                                      'sqlite3'    => 'sqlite');
 
 
     /**
@@ -79,6 +122,13 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
         $this->password = $password;
         $this->listener = new Doctrine_DB_EventListener();
     }
+
+    /**
+     * getQuerySequence
+     */
+    public function getQuerySequence() {
+        return $this->querySequence;
+    }
     /**
      * getDBH
      */
@@ -303,31 +353,36 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
 
         $args = func_get_args();
 
-        $this->listener->onPrePrepare($this, $args);
+        $this->listener->onPrePrepare($this, $statement, $args);
 
         $stmt = $this->dbh->prepare($statement);
 
-        $this->listener->onPrepare($this, $args);
-        
+        $this->listener->onPrepare($this, $statement, $args, $this->querySequence);
+
+        $this->querySequence++;
+
         return $stmt;
     }
     /**
      * query
      *
      * @param string $statement
+     * @param array $params
      * @return Doctrine_DB_Statement|boolean
      */
     public function query($statement, array $params = array()) {
         $this->connect();
 
-        $this->listener->onPreQuery($this, $params);
+        $this->listener->onPreQuery($this, $statement, $params);
         
         if( ! empty($params)) 
             $stmt = $this->dbh->query($statement)->execute($params);
         else
             $stmt = $this->dbh->query($statement);
 
-        $this->listener->onQuery($this, $params);
+        $this->listener->onQuery($this, $statement, $params, $this->querySequence);
+
+        $this->querySequence++;
 
         return $stmt;
     }
@@ -355,11 +410,11 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
 
         $args = func_get_args();
 
-        $this->listener->onPreExec($this, $args);
+        $this->listener->onPreExec($this, $statement, $args);
 
         $rows = $this->dbh->exec($statement);
 
-        $this->listener->onExec($this, $args);
+        $this->listener->onExec($this, $statement, $args);
 
         return $rows;
     }
@@ -477,7 +532,8 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
      * @return ArrayIterator
      */
     public function getIterator() {
-        return new ArrayIterator($this->queries);
+        if($this->listener instanceof Doctrine_DB_Profiler)
+            return $this->listener;
     }
     /**
      * count
@@ -486,7 +542,7 @@ class Doctrine_DB2 implements Countable, IteratorAggregate {
      * @return integer
      */
     public function count() {
-        return count($this->queries);
+        return $this->querySequence;
     }
 
 }
diff --git a/lib/Doctrine.php b/lib/Doctrine.php
index d685e21a5..75cb07b9d 100644
--- a/lib/Doctrine.php
+++ b/lib/Doctrine.php
@@ -152,12 +152,15 @@ final class Doctrine {
     /**
      * automatic length validations attribute
      */
-    const ATTR_AUTO_LENGTH_VLD = 19;
+    const ATTR_AUTO_LENGTH_VLD  = 19;
     /**
      * automatic type validations attribute
      */
-    const ATTR_AUTO_TYPE_VLD = 20;
-    
+    const ATTR_AUTO_TYPE_VLD    = 20;
+    /**
+     * short aliases attribute
+     */
+    const ATTR_SHORT_ALIASES    = 21;
     
     /**
      * LIMIT CONSTANTS
diff --git a/lib/Doctrine/Configurable.php b/lib/Doctrine/Configurable.php
index ef9e58c0f..27e9703ac 100644
--- a/lib/Doctrine/Configurable.php
+++ b/lib/Doctrine/Configurable.php
@@ -117,6 +117,7 @@ abstract class Doctrine_Configurable {
             case Doctrine::ATTR_VLD:
             case Doctrine::ATTR_AUTO_LENGTH_VLD:
             case Doctrine::ATTR_AUTO_TYPE_VLD:
+            case Doctrine::ATTR_SHORT_ALIASES:
             case Doctrine::ATTR_QUERY_LIMIT:
 
             break;
@@ -190,8 +191,8 @@ abstract class Doctrine_Configurable {
     public function getAttribute($attribute) {
         $attribute = (int) $attribute;
 
-        if($attribute < 1 || $attribute > 20)
-            throw new InvalidKeyException();
+        if($attribute < 1 || $attribute > 21)
+            throw new Doctrine_Exception('Unknown attribute.');
 
         if( ! isset($this->attributes[$attribute])) {
             if(isset($this->parent))
diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php
index bb9d6c35c..8e23f4ea7 100644
--- a/lib/Doctrine/Connection.php
+++ b/lib/Doctrine/Connection.php
@@ -444,6 +444,12 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
      * returns an iterator that iterators through all 
      * initialized table objects
      *
+     * <code>
+     * foreach($conn as $index => $table) {
+     *      print $table;  // get a string representation of each table object
+     * }
+     * </code>
+     *
      * @return ArrayIterator
      */
     public function getIterator() {
diff --git a/lib/Doctrine/DB/EventListener.php b/lib/Doctrine/DB/EventListener.php
index af1df67e2..3a2390637 100644
--- a/lib/Doctrine/DB/EventListener.php
+++ b/lib/Doctrine/DB/EventListener.php
@@ -26,17 +26,17 @@
  * @package     Doctrine
  */
 class Doctrine_DB_EventListener implements Doctrine_DB_EventListener_Interface {
-    public function onPreQuery(Doctrine_DB2 $dbh, array $args) { }
-    public function onQuery(Doctrine_DB2 $dbh, array $args) { }
+    public function onPreQuery(Doctrine_DB2 $dbh, $statement, array $args) { }
+    public function onQuery(Doctrine_DB2 $dbh, $statement, array $args, $queryId) { }
 
-    public function onPrePrepare(Doctrine_DB2 $dbh, array $args) { }
-    public function onPrepare(Doctrine_DB2 $dbh, array $args) { }
+    public function onPrePrepare(Doctrine_DB2 $dbh, $statement, array $args) { }
+    public function onPrepare(Doctrine_DB2 $dbh, $statement, array $args, $queryId) { }
 
     public function onPreCommit(Doctrine_DB2 $dbh) { }
     public function onCommit(Doctrine_DB2 $dbh) { }
 
-    public function onPreExec(Doctrine_DB2 $dbh, array $args) { }
-    public function onExec(Doctrine_DB2 $dbh, array $args) { }
+    public function onPreExec(Doctrine_DB2 $dbh, $statement, array $args) { }
+    public function onExec(Doctrine_DB2 $dbh, $statement, array $args) { }
 
     public function onPreRollBack(Doctrine_DB2 $dbh) { }
     public function onRollBack(Doctrine_DB2 $dbh) { }
diff --git a/lib/Doctrine/DB/EventListener/Chain.php b/lib/Doctrine/DB/EventListener/Chain.php
index 8fc794c92..c50e73d99 100644
--- a/lib/Doctrine/DB/EventListener/Chain.php
+++ b/lib/Doctrine/DB/EventListener/Chain.php
@@ -54,12 +54,12 @@ class Doctrine_DB_EventListener_Chain extends Doctrine_Access implements Doctrin
         $this->listeners[$name] = $listener;
     }
 
-    public function onPreQuery(Doctrine_DB2 $dbh, array $args) {
+    public function onQuery(Doctrine_DB2 $dbh, $statement, array $args, $queryId) {
         foreach($this->listeners as $listener) {
             $listener->onPreQuery($dbh, $args);
         }
     }
-    public function onQuery(Doctrine_DB2 $dbh, array $args) {
+    public function onPreQuery(Doctrine_DB2 $dbh, $statement, array $args) {
         foreach($this->listeners as $listener) {
             $listener->onQuery($dbh, $args);
         }
diff --git a/lib/Doctrine/DB/EventListener/Interface.php b/lib/Doctrine/DB/EventListener/Interface.php
index 956431de5..64b0ae646 100644
--- a/lib/Doctrine/DB/EventListener/Interface.php
+++ b/lib/Doctrine/DB/EventListener/Interface.php
@@ -26,14 +26,14 @@
  * @package     Doctrine
  */
 interface Doctrine_DB_EventListener_Interface {
-    public function onPreQuery(Doctrine_DB2 $dbh, array $args);
-    public function onQuery(Doctrine_DB2 $dbh, array $args);
+    public function onPreQuery(Doctrine_DB2 $dbh, $statement, array $args);
+    public function onQuery(Doctrine_DB2 $dbh, $statement, array $args, $queryId);
 
-    public function onPrePrepare(Doctrine_DB2 $dbh, array $args);
-    public function onPrepare(Doctrine_DB2 $dbh, array $args);
+    public function onPrePrepare(Doctrine_DB2 $dbh, $statement, array $args);
+    public function onPrepare(Doctrine_DB2 $dbh, $statement, array $args, $queryId);
 
-    public function onPreExec(Doctrine_DB2 $dbh, array $args);
-    public function onExec(Doctrine_DB2 $dbh, array $args);
+    public function onPreExec(Doctrine_DB2 $dbh, $statement, array $args);
+    public function onExec(Doctrine_DB2 $dbh, $statement, array $args);
 
     public function onPreCommit(Doctrine_DB2 $dbh);
     public function onCommit(Doctrine_DB2 $dbh);
diff --git a/lib/Doctrine/DB/Profiler.php b/lib/Doctrine/DB/Profiler.php
index d09cc73d9..ded5bef70 100644
--- a/lib/Doctrine/DB/Profiler.php
+++ b/lib/Doctrine/DB/Profiler.php
@@ -26,25 +26,225 @@
  * @package     Doctrine
  */
 class Doctrine_DB_Profiler extends Doctrine_DB_EventListener {
-    private $queries;
-
-    public function onPreQuery(Doctrine_DB $dbh, array $args) { 
-        $this->queries[] = $args[0];
+    public function onPreQuery(Doctrine_DB2 $dbh, $statement, array $args) {
+        $this->queryStart($statement);
+    }
+    public function onQuery(Doctrine_DB2 $dbh, $statement, array $args, $queryId) {
+        $this->queryEnd($queryId);
     }
-    public function onQuery(Doctrine_DB $dbh, array $args) { }
 
-    public function onPrePrepare(Doctrine_DB $dbh, array $args) { }
-    public function onPrepare(Doctrine_DB $dbh, array $args) { }
+    public function onPrePrepare(Doctrine_DB2 $dbh, $statement, array $args) {
+        $this->prepareTimes[$dbh->getQuerySequence()] = microtime(true);
+    }
+    public function onPrepare(Doctrine_DB2 $dbh, $statement, array $args, $queryId) { 
+        $this->prepareTimes[$queryId] = (microtime(true) - $this->prepareTimes[$queryId]);
+    }
 
-    public function onPreCommit(Doctrine_DB $dbh) { }
-    public function onCommit(Doctrine_DB $dbh) { }
+    public function onPreCommit(Doctrine_DB2 $dbh) { }
+    public function onCommit(Doctrine_DB2 $dbh) { }
 
-    public function onPreRollBack(Doctrine_DB $dbh) { }
-    public function onRollBack(Doctrine_DB $dbh) { }
+    public function onPreRollBack(Doctrine_DB2 $dbh) { }
+    public function onRollBack(Doctrine_DB2 $dbh) { }
 
-    public function onPreBeginTransaction(Doctrine_DB $dbh) { }
-    public function onBeginTransaction(Doctrine_DB $dbh) { }
+    public function onPreBeginTransaction(Doctrine_DB2 $dbh) { }
+    public function onBeginTransaction(Doctrine_DB2 $dbh) { }
 
-    public function onPreExecute(Doctrine_DB_Statement $stmt, array $params) { }
-    public function onExecute(Doctrine_DB_Statement $stmt, array $params) { }
+    public function onPreExecute(Doctrine_DB_Statement $stmt, array $params) {
+        $this->queryStart($stmt->getQuery(), $stmt->getQuerySequence());
+    }
+    public function onExecute(Doctrine_DB_Statement $stmt, array $params) { 
+        $this->queryEnd($stmt->getQuerySequence());
+    }
+    /**
+     * Array of Zend_Db_Profiler_Query objects.
+     *
+     * @var Zend_Db_Profiler_Query
+     */
+    protected $_queryProfiles = array();
+
+
+    protected $_prepareTimes  = array();
+    /**
+     * Stores the number of seconds to filter.  NULL if filtering by time is
+     * disabled.  If an integer is stored here, profiles whose elapsed time
+     * is less than this value in seconds will be unset from
+     * the self::$_queryProfiles array.
+     *
+     * @var integer
+     */
+    protected $_filterElapsedSecs = null;
+
+    /**
+     * Logical OR of any of the filter constants.  NULL if filtering by query
+     * type is disable.  If an integer is stored here, it is the logical OR of
+     * any of the query type constants.  When the query ends, if it is not
+     * one of the types specified, it will be unset from the
+     * self::$_queryProfiles array.
+     *
+     * @var integer
+     */
+    protected $_filterTypes = null;
+
+
+    /**
+     * Start a query.  Creates a new query profile object (Zend_Db_Profiler_Query)
+     * and returns the "query profiler handle".  Run the query, then call
+     * queryEnd() and pass it this handle to make the query as ended and
+     * record the time.  If the profiler is not enabled, this takes no
+     * action and immediately runs.
+     *
+     * @param string $queryText     SQL statement
+     * @param int $queryType        Type of query, one of the Zend_Db_Profiler::* constants
+     * @return mixed
+     */
+    public function queryStart($queryText, $querySequence = -1) {
+        $prepareTime = (isset($this->prepareTimes[$querySequence])) ? $this->prepareTimes[$querySequence] : null;
+
+        $this->_queryProfiles[] = new Doctrine_DB_Profiler_Query($queryText, $prepareTime);
+    }
+    /**
+     * Ends a query.  Pass it the handle that was returned by queryStart().
+     * This will mark the query as ended and save the time.
+     *
+     * @param integer $queryId
+     * @throws Zend_Db_Profiler_Exception
+     * @return boolean
+     */
+    public function queryEnd($queryId = null) {
+
+
+        // Check for a valid query handle.
+        if($queryId === null) 
+            $qp = end($this->_queryProfiles);
+        else
+            $qp = $this->_queryProfiles[$queryId];
+
+
+        if($qp === null || $qp->hasEnded()) {
+            throw new Zend_Db_Profiler_Exception('Query with profiler handle "'
+                                          . $queryId .'" has already ended.');
+        }
+
+        // End the query profile so that the elapsed time can be calculated.
+        $qp->end();
+    }
+
+
+    /**
+     * Get a profile for a query.  Pass it the same handle that was returned
+     * by queryStart() and it will return a Zend_Db_Profiler_Query object.
+     *
+     * @param int $queryId
+     * @throws Zend_Db_Profiler_Exception
+     * @return Zend_Db_Profiler_Query
+     */
+    public function getQueryProfile($queryId)
+    {
+        if (!array_key_exists($queryId, $this->_queryProfiles)) {
+            throw new Zend_Db_Profiler_Exception("Query handle \"$queryId\" not found in profiler log.");
+        }
+
+        return $this->_queryProfiles[$queryId];
+    }
+
+
+    /**
+     * Get an array of query profiles (Zend_Db_Profiler_Query objects).  If $queryType
+     * is set to one of the Zend_Db_Profiler::* constants then only queries of that
+     * type will be returned.  Normally, queries that have not yet ended will
+     * not be returned unless $showUnfinished is set to True.  If no
+     * queries were found, False is returned.
+     *
+     * @param string $queryType
+     * @param bool $showUnfinished
+     * @return mixed
+     */
+    public function getQueryProfiles($queryType=null, $showUnfinished=false)
+    {
+        $queryProfiles = array();
+        foreach ($this->_queryProfiles as $key=>$qp) {
+            /* @var $qp Zend_Db_Profiler_Query */
+            if ($queryType===null) {
+                $condition=true;
+            } else {
+                $condition=($qp->getQueryType() & $queryType);
+            }
+
+            if (($qp->hasEnded() || $showUnfinished) && $condition) {
+                $queryProfiles[$key] = $qp;
+            }
+        }
+
+        if (empty($queryProfiles)) {
+            $queryProfiles = false;
+        }
+        return $queryProfiles;
+    }
+
+
+    /**
+     * Get the total elapsed time (in seconds) of all of the profiled queries.
+     * Only queries that have ended will be counted.  If $queryType is set to
+     * one of the Zend_Db_Profiler::* constants, the elapsed time will be calculated
+     * only for queries of that type.
+     *
+     * @param int $queryType
+     * @return int
+     */
+    public function getTotalElapsedSecs($queryType = null)
+    {
+        $elapsedSecs = 0;
+        foreach ($this->_queryProfiles as $key=>$qp) {
+            /* @var $qp Zend_Db_Profiler_Query */
+            is_null($queryType)? $condition=true : $condition=($qp->getQueryType() & $queryType);
+            if (($qp->hasEnded()) && $condition) {
+                $elapsedSecs += $qp->getElapsedSecs();
+            }
+        }
+        return $elapsedSecs;
+    }
+
+
+    /**
+     * Get the total number of queries that have been profiled.  Only queries that have ended will
+     * be counted.  If $queryType is set to one of the Zend_Db_Profiler::* constants, only queries of
+     * that type will be counted.
+     *
+     * @param int $queryType
+     * @return int
+     */
+    public function getTotalNumQueries($queryType = null)
+    {
+        if (is_null($queryType)) {
+            return sizeof($this->_queryProfiles);
+        }
+
+        $numQueries = 0;
+        foreach ($this->_queryProfiles as $qp) {
+            /* @var $qp Zend_Db_Profiler_Query */
+            is_null($queryType)? $condition=true : $condition=($qp->getQueryType() & $queryType);
+            if ($qp->hasEnded() && $condition) {
+                $numQueries++;
+            }
+        }
+        return $numQueries;
+    }
+
+    public function pop() {
+        return array_pop($this->_queryProfiles);
+    }
+    /**
+     * Get the Zend_Db_Profiler_Query object for the last query that was run, regardless if it has
+     * ended or not.  If the query has not ended, it's end time will be Null.
+     *
+     * @return Zend_Db_Profiler_Query
+     */
+    public function lastQuery() {
+        if (empty($this->_queryProfiles)) {
+            return false;
+        }
+
+        end($this->_queryProfiles);
+        return current($this->_queryProfiles);
+    }
 }
diff --git a/lib/Doctrine/DB/Profiler/Query.php b/lib/Doctrine/DB/Profiler/Query.php
new file mode 100644
index 000000000..ff4dda2db
--- /dev/null
+++ b/lib/Doctrine/DB/Profiler/Query.php
@@ -0,0 +1,126 @@
+<?php
+/*
+ *  $Id$
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information, see
+ * <http://www.phpdoctrine.com>.
+ */
+
+/**
+ * Doctrine_DB_Profiler_Query
+ *
+ * @author      Konsta Vesterinen
+ * @license     LGPL
+ * @package     Doctrine
+ */
+class Doctrine_DB_Profiler_Query {
+    /**
+     * @var string      SQL query string or user comment, set by $query argument in constructor.
+     */
+    protected $query ='';
+    /**
+     * @var integer     One of the Zend_Db_Profiler constants for query type, set by $queryType argument in constructor.
+     */
+    protected $queryType = 0;
+
+
+    protected $prepareTime;
+
+    /**
+     * @var float|null  Unix timestamp with microseconds when instantiated.
+     */
+    protected $startedMicrotime;
+
+    /**
+     * Unix timestamp with microseconds when self::queryEnd() was called.
+     *
+     * @var null|integer
+     */
+    protected $endedMicrotime;
+
+
+    /**
+     * Class constructor.  A query is about to be started, save the query text ($query) and its
+     * type (one of the Zend_Db_Profiler::* constants).
+     *
+     * @param string $query
+     * @param int $queryType
+     * @return bool
+     */
+    public function __construct($query, $prepareTime = null)
+    {
+        $this->query = $query;
+        $this->prepareTime = $prepareTime;
+        $this->startedMicrotime = microtime(true);
+        return true;
+    }
+    /**
+     * The query has ended.  Record the time so that the elapsed time can be determined later.
+     *
+     * @return bool
+     */
+    public function end() {
+        $this->endedMicrotime = microtime(true);
+        return true;
+    }
+
+    public function getPrepareTime() {
+        return $this->prepareTime;
+    }
+
+    /**
+     * Has this query ended?
+     *
+     * @return bool
+     */
+    public function hasEnded() {
+        return ($this->endedMicrotime != null);
+    }
+
+
+    /**
+     * Get the original SQL text of the query.
+     *
+     * @return string
+     */
+    public function getQuery() {
+        return $this->query;
+    }
+
+
+    /**
+     * Get the type of this query (one of the Zend_Db_Profiler::* constants)
+     *
+     * @return int
+     */
+    public function getQueryType() {
+        return $this->queryType;
+    }
+    /**
+     * Get the elapsed time (in seconds) that the query ran.  If the query has
+     * not yet ended, return false.
+     *
+     * @return mixed
+     */
+    public function getElapsedSecs() {
+        if (is_null($this->endedMicrotime) && ! $this->prepareTime) {
+            return false;
+        }
+
+        return ($this->prepareTime + ($this->endedMicrotime - $this->startedMicrotime));
+    }
+}
+
diff --git a/lib/Doctrine/DB/Statement.php b/lib/Doctrine/DB/Statement.php
index c45eb2f50..417c2b369 100644
--- a/lib/Doctrine/DB/Statement.php
+++ b/lib/Doctrine/DB/Statement.php
@@ -27,12 +27,22 @@
  */
 class Doctrine_DB_Statement extends PDOStatement { 
     protected $dbh;
-    
+
+    protected $querySequence;
+
     protected function __construct($dbh) {
         $this->dbh = $dbh;
+        $this->querySequence = $this->dbh->getQuerySequence();
     }
     
-    public function execute($params) {
+    public function getQuerySequence() {
+        return $this->querySequence;
+    }
+    public function getQuery() {
+        return $this->queryString;
+    }
+
+    public function execute(array $params) {
         $this->dbh->getListener()->onPreExecute($this, $params);
         
         $ret = parent::execute($params);
diff --git a/lib/Doctrine/DataDict/Sqlite.php b/lib/Doctrine/DataDict/Sqlite.php
index 85b1fcad6..b7ea84f30 100644
--- a/lib/Doctrine/DataDict/Sqlite.php
+++ b/lib/Doctrine/DataDict/Sqlite.php
@@ -274,7 +274,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
      */
     public function listTableColumns($table) { 
 
-        $sql    = "PRAGMA table_info($table)";
+        $sql    = 'PRAGMA table_info(' . $table . ')';
         $result = $this->dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
 
         $description = array();
diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php
index fd02a3df2..87776742a 100644
--- a/lib/Doctrine/Hydrate.php
+++ b/lib/Doctrine/Hydrate.php
@@ -88,6 +88,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
     protected $pendingAggregates = array();
 
     protected $aggregateMap      = array();
+    
+    protected $shortAliases      = array();
+    
+    protected $shortAliasIndexes = array();
     /**
      * @var array $parts            SQL query string parts
      */
@@ -227,6 +231,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
         $this->joins            = array();
         $this->tableIndexes     = array();
         $this->tableAliases     = array();
+        $this->shortAliases     = array();
+        $this->shortAliasIndexes = array();
     }
     /**
      * getConnection
@@ -371,6 +377,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
             foreach($data as $key => $row) {
                 if(empty($row))
                     continue;
+                
+                //$key = array_search($key, $this->shortAliases);
 
                 foreach($this->tables as $k => $t) {
                     if ( ! strcasecmp($key, $k))
@@ -391,9 +399,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
                         if(isset($row[0])) {
                             $path    = array_search($name, $this->tableAliases);
                             $alias   = $this->getPathAlias($path);
-                            
-                            //print_r($this->pendingAggregates);
-                            
+
                             // map each aggregate value
                             foreach($row as $index => $value) {
                                 $agg = false;
@@ -487,7 +493,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
         $pointer = $this->joins[$name];
 
         $path    = array_search($name, $this->tableAliases);
-        $tmp     = explode(".", $path);
+        $tmp     = explode('.', $path);
         $alias   = end($tmp);
 
         $fk      = $this->tables[$pointer]->getRelation($alias);
@@ -533,6 +539,36 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
         }
         return false;
     }
+    public function getShortAliasIndex($alias) {
+        if( ! isset($this->shortAliasIndexes[$alias]))
+            return 0;
+        
+        return $this->shortAliasIndexes[$alias];
+    }
+    public function generateShortAlias($tableName) {
+        $char   = strtolower(substr($tableName, 0, 1));
+
+        $alias  = $char;
+
+        if( ! isset($this->shortAliasIndexes[$alias]))
+            $this->shortAliasIndexes[$alias] = 1;
+
+        while(isset($this->shortAliases[$alias])) {
+            $alias = $char . ++$this->shortAliasIndexes[$alias];
+        }
+        $this->shortAliases[$alias] = $tableName;
+
+        return $alias;
+    }
+
+    public function getShortAlias($tableName) {
+        $alias = array_search($tableName, $this->shortAliases);
+
+        if($alias !== false)
+            return $alias;
+        
+        return $this->generateShortAlias($tableName);
+    }
     /**
      * applyInheritance
      * applies column aggregation inheritance to DQL / SQL query
@@ -552,23 +588,29 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
         $c = array();
 
         $index = 0;
-        foreach($array as $tname => $maps) {
+        foreach($array as $tableAlias => $maps) {
+
             $a = array();
             foreach($maps as $map) {
                 $b = array();
                 foreach($map as $field => $value) {
                     if($index > 0)
-                        $b[] = "(".$tname.".$field = $value OR $tname.$field IS NULL)";
+                        $b[] = '(' . $tableAlias . '.' . $field . ' = ' . $value . ' OR ' . $tableAlias . '.' . $field . ' IS NULL)';
                     else
-                        $b[] = $tname.".$field = $value";
+                        $b[] = $tableAlias . '.' . $field . ' = ' . $value;
                 }
-                if( ! empty($b)) $a[] = implode(" AND ",$b);
+            
+                if( ! empty($b))
+                    $a[] = implode(' AND ', $b);
             }
-            if( ! empty($a)) $c[] = implode(" AND ",$a);
+
+            if( ! empty($a))
+                $c[] = implode(' AND ', $a);
+
             $index++;
         }
 
-        $str .= implode(" AND ",$c);
+        $str .= implode(' AND ', $c);
 
         return $str;
     }
@@ -576,6 +618,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
      * parseData
      * parses the data returned by PDOStatement
      *
+     * @param PDOStatement $stmt
      * @return array
      */
     public function parseData(PDOStatement $stmt) {
diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php
index 7f15bcb07..ac9e42193 100644
--- a/lib/Doctrine/Manager.php
+++ b/lib/Doctrine/Manager.php
@@ -93,7 +93,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
                         Doctrine::ATTR_AUTO_LENGTH_VLD  => true,
                         Doctrine::ATTR_AUTO_TYPE_VLD    => true,
                         Doctrine::ATTR_CREATE_TABLES    => true,
-                        Doctrine::ATTR_QUERY_LIMIT      => Doctrine::LIMIT_RECORDS
+                        Doctrine::ATTR_QUERY_LIMIT      => Doctrine::LIMIT_RECORDS,
+                        Doctrine::ATTR_SHORT_ALIASES    => false,
                         );
             foreach($attributes as $attribute => $value) {
                 $old = $this->getAttribute($attribute);
diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php
index f388f790b..48b2dae1e 100644
--- a/lib/Doctrine/Query.php
+++ b/lib/Doctrine/Query.php
@@ -97,7 +97,8 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
 
     public function processPendingFields($componentAlias) {
         $tableAlias = $this->getTableAlias($componentAlias);
-        
+
+
         $componentPath  = $this->compAliases[$componentAlias];
 
         if( ! isset($this->components[$componentPath])) 
@@ -249,9 +250,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
 
         foreach($names as $name) {
             if($count == 0) {
-                $this->parts["select"][] = $tablename.".".$name;
+                $this->parts["select"][] = $tablename . '.' . $name;
             } else {
-                $this->parts["select"][] = $tablename.".".$name." AS ".$tablename."__".$name;
+                $this->parts["select"][] = $tablename . '.' . $name . ' AS ' . $tablename . '__' . $name;
             }
         }
     }
@@ -322,6 +323,8 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
                 $this->fetchModes       = array();
                 $this->tableIndexes     = array();
                 $this->tableAliases     = array();
+                $this->shortAliases     = array();
+                $this->shortAliasIndexes = array();
 
                 $class = "Doctrine_Query_".ucwords($name);
                 $parser = new $class($this);
@@ -462,10 +465,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
              ' FROM ';
         $q = $this->getQueryBase();
 
-        foreach($this->parts["from"] as $tname => $bool) {
-            $a[] = $tname;
-        }
-        $q .= implode(", ",$a);
+        $q .= $this->parts['from'];
 
         if( ! empty($this->parts['join'])) {
             foreach($this->parts['join'] as $part) {
@@ -498,7 +498,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
                     break;
                 }
 
-                $field    = $table->getTableName() . '.' . $table->getIdentifier();
+                $field    = $this->getShortAlias($table->getTableName()) . '.' . $table->getIdentifier();
                 array_unshift($this->parts['where'], $field. ' IN (' . $subquery . ')');
                 $modifyLimit = false;
             }
@@ -533,7 +533,8 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
         $k          = array_keys($this->tables);
         $table      = $this->tables[$k[0]];
 
-        $primaryKey = $table->getTableName() . '.' . $table->getIdentifier();
+        $alias      = $this->getShortAlias($table->getTableName());
+        $primaryKey = $alias . '.' . $table->getIdentifier();
 
         // initialize the base of the subquery
         $subquery   = 'SELECT DISTINCT ' . $primaryKey;
@@ -550,15 +551,15 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
             }
         }
 
-        $subquery .= ' FROM '.$table->getTableName();
-        
+        $subquery .= ' FROM ' . $table->getTableName() . ' ' . $alias;
+
         foreach($this->parts['join'] as $parts) {
             foreach($parts as $part) {
                 // preserve LEFT JOINs only if needed
                 if(substr($part,0,9) === 'LEFT JOIN') {
                     $e = explode(' ', $part);
 
-                    if( ! in_array($e[2],$this->subqueryAliases))
+                    if( ! in_array($e[3], $this->subqueryAliases))
                         continue;
                 }
 
@@ -566,6 +567,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
             }
         }
 
+
         // all conditions must be preserved in subquery
         $subquery .= ( ! empty($this->parts['where']))?   ' WHERE '    . implode(' AND ',$this->parts['where']):'';
         $subquery .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ',$this->parts['groupby']):'';
@@ -574,9 +576,48 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
 
         // add driver specific limit clause
         $subquery = $this->connection->modifyLimitQuery($subquery, $this->parts['limit'], $this->parts['offset']);
-    
+
+        $parts = self::quoteExplode($subquery, ' ', "'", "'");
+
+        foreach($parts as $k => $part) {
+            if(strpos($part, "'") !== false)
+                continue;
+
+            if(isset($this->shortAliases[$part])) {
+                $parts[$k] = $this->generateNewAlias($part);
+            }
+
+            if(strpos($part, '.') !== false) {
+                $e = explode('.', $part);
+                
+                $trimmed = ltrim($e[0], '( ');
+                $pos     = strpos($e[0], $trimmed);
+
+                $e[0] = substr($e[0], 0, $pos) . $this->generateNewAlias($trimmed);
+                $parts[$k] = implode('.', $e);
+            }
+        }
+        $subquery = implode(' ', $parts);
+
         return $subquery;
     }
+    
+    public function generateNewAlias($alias) {
+        if(isset($this->shortAliases[$alias])) {
+            // generate a new alias
+            $name = substr($alias, 0, 1);
+            $i    = ((int) substr($alias, 1));
+
+            if($i == 0)
+                $i = 1;
+
+            $newIndex  = ($this->shortAliasIndexes[$name] + $i);
+
+            return $name . $newIndex;
+        }
+        
+        return $alias;
+    }
 
 
 
@@ -592,7 +633,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
         if($this->aggregate) {
             $keys  = array_keys($this->tables);
             $query = $this->getQuery();
-            $stmt  = $this->tables[$keys[0]]->getConnection()->select($query,$this->parts["limit"],$this->parts["offset"]);
+            $stmt  = $this->tables[$keys[0]]->getConnection()->select($query, $this->parts["limit"], $this->parts["offset"]);
             $data  = $stmt->fetch(PDO::FETCH_ASSOC);
             if(count($data) == 1) {
                 return current($data);
@@ -825,6 +866,47 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
         }
         return $term;
     }
+    /**
+     * quoteExplode
+     *
+     * example:
+     * 
+     * parameters:
+     *      $str = email LIKE 'John@example.com'
+     *      $d = ' AND '
+     *      $e1 = '('
+     *      $e2 = ')'
+     *
+     * would return an array:
+     *      array("email", "LIKE", "'John@example.com'")
+     *
+     * @param string $str
+     * @param string $d         the delimeter which explodes the string       *
+     */
+    public static function quoteExplode($str, $d = ' ') {
+        if(is_array($d)) {
+            $a = preg_split('/('.implode('|', $d).')/', $str);
+            $d = stripslashes($d[0]);
+        } else
+            $a = explode("$d",$str);
+
+        $i = 0;
+        $term = array();
+        foreach($a as $key => $val) {
+            if (empty($term[$i])) {
+                $term[$i] = trim($val);
+
+                if( ! (substr_count($term[$i], "'") & 1))
+                    $i++;
+            } else {
+                $term[$i] .= "$d".trim($val);
+
+                if( ! (substr_count($term[$i], "'") & 1))
+                    $i++;
+            }
+        }
+        return $term;
+    }
     /**
      * sqlExplode
      *
@@ -944,25 +1026,26 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
                 $e2    = preg_split("/[-(]/",$fullname);
                 $name  = $e2[0];
 
-                $currPath .= ".".$name;
+                $currPath .= '.' . $name;
 
                 if($key == 0) {
                     $currPath = substr($currPath,1);
 
-
-
                     $table = $this->connection->getTable($name);
 
-                    $tname = $table->getTableName();
+
+                    $tname = $this->getShortAlias($table->getTableName());
 
                     if( ! isset($this->tableAliases[$currPath]))
                         $this->tableIndexes[$tname] = 1;
 
-                    $this->parts["from"][$tname]   = true;
+
+                    $this->parts["from"]           = $table->getTableName() . ' ' . $tname;
 
                     $this->tableAliases[$currPath] = $tname;
-                    
+
                     $tableName = $tname;
+
                 } else {
 
                     $index += strlen($e[($key - 1)]) + 1;
@@ -972,7 +1055,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
                     if(isset($this->tableAliases[$prevPath])) {
                         $tname = $this->tableAliases[$prevPath];
                     } else
-                        $tname = $table->getTableName();
+                        $tname = $this->getShortAlias($table->getTableName());
 
 
                     $fk       = $table->getRelation($name);
@@ -984,18 +1067,15 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
                     if(isset($this->tableAliases[$currPath])) {
                         $tname2 = $this->tableAliases[$currPath];
                     } else
-                        $tname2 = $this->generateAlias($original);
+                        $tname2 = $this->generateShortAlias($original);
 
-                    if($original !== $tname2) 
-                        $aliasString = $original." AS ".$tname2;
-                    else
-                        $aliasString = $original;
+                    $aliasString = $original . ' ' . $tname2;
 
                     switch($mark) {
-                        case ":":
+                        case ':':
                             $join = 'INNER JOIN ';
                         break;
-                        case ".":
+                        case '.':
                             $join = 'LEFT JOIN ';
                         break;
                         default:
@@ -1003,36 +1083,44 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
                     }
 
                     if( ! $fk->isOneToOne()) {
-                        if( ! $loadFields) {
+                        if( ! $loadFields || $table->usesInheritanceMap()) {
                             $this->subqueryAliases[] = $tname2;
                         }
                         
                         $this->needsSubquery = true;
                     }
-                    
+
                     if($fk instanceof Doctrine_Relation_Association) {
                         $asf = $fk->getAssociationFactory();
 
                         $assocTableName = $asf->getTableName();
-                        
-                        if( ! $loadFields) {
+
+                        if( ! $loadFields || $table->usesInheritanceMap()) {
                             $this->subqueryAliases[] = $assocTableName;
                         }
-                        $this->parts["join"][$tname][$assocTableName] = $join.$assocTableName .' ON '.$tname.".".$table->getIdentifier()." = ".$assocTableName.".".$fk->getLocal();
-                        $this->parts["join"][$tname][$tname2]         = $join.$aliasString    .' ON '.$tname2.".".$table->getIdentifier()." = ".$assocTableName.".".$fk->getForeign();
+                        $this->parts["join"][$tname][$assocTableName] = $join.$assocTableName . ' ON ' .$tname  . '.' 
+                                                                      . $table->getIdentifier() . ' = '
+                                                                      . $assocTableName . '.' . $fk->getLocal();
+
+                        $this->parts["join"][$tname][$tname2]         = $join.$aliasString    . ' ON ' .$tname2 . '.'
+                                                                      . $table->getIdentifier() . ' = '
+                                                                      . $assocTableName . '.' . $fk->getForeign();
 
                     } else {
-                        $this->parts["join"][$tname][$tname2]         = $join.$aliasString    .' ON '.$tname.".".$fk->getLocal()." = ".$tname2.".".$fk->getForeign();
+                        $this->parts["join"][$tname][$tname2]         = $join.$aliasString    . ' ON ' .$tname .  '.'
+                                                                      . $fk->getLocal() . ' = ' . $tname2 . '.' . $fk->getForeign();
                     }
 
+
                     $this->joins[$tname2] = $prevTable;
 
 
                     $table = $fk->getTable();
+
                     $this->tableAliases[$currPath] = $tname2;
 
                     $tableName = $tname2;
-                    
+
                     $this->relationStack[] = $fk;
                 }
                 
diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php
index 9a81d928b..72492aa91 100644
--- a/lib/Doctrine/Table.php
+++ b/lib/Doctrine/Table.php
@@ -292,6 +292,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
         }
         $this->options[$name] = $value;
     }
+    
+    public function usesInheritanceMap() {
+        return ( ! empty($this->options['inheritanceMap']));
+    }
+    public function getOption($name) {
+        if(isset($this->options[$name]))
+            return $this->options[$name];
+            
+        return null;
+    }
     /**
      * setColumn
      * @param string $name
diff --git a/tests/DBTestCasee.php b/tests/DBTestCasee.php
deleted file mode 100644
index e99fbc99f..000000000
--- a/tests/DBTestCasee.php
+++ /dev/null
@@ -1,385 +0,0 @@
-<?php
-require_once("../draft/DB.php");
-
-class Doctrine_DB_TestLogger implements Doctrine_Overloadable {
-    private $messages = array();
-    
-    public function __call($m, $a) {
-        $this->messages[] = $m;
-    }
-    public function pop() {
-        return array_pop($this->messages);
-    }
-    public function getAll() {
-        return $this->messages;
-    }
-}
-class Doctrine_DB_TestValidListener extends Doctrine_DB_EventListener { }
-class Doctrine_DB_TestInvalidListener { }
-
-class Doctrine_DB_TestCase extends Doctrine_UnitTestCase {
-    public function prepareData() { }
-    public function prepareTables() { }
-    public function init() { }
-
-    public function testFetchAll() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-        $dbh->connect();
-
-
-        $dbh->query('CREATE TABLE entity (id INTEGER, name TEXT)');
-
-        $dbh->query("INSERT INTO entity (id, name) VALUES (1, 'zYne')");
-        $dbh->query("INSERT INTO entity (id, name) VALUES (2, 'John')");
-
-        $a = $dbh->fetchAll('SELECT * FROM entity');
-
-
-        $this->assertEqual($a, array (
-                            0 =>
-                            array (
-                              'id' => '1',
-                              'name' => 'zYne',
-                            ),
-                            1 =>
-                            array (
-                              'id' => '2',
-                              'name' => 'John',
-                            ),
-                          ));
-    }
-    public function testFetchOne() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-
-        $c = $dbh->fetchOne('SELECT COUNT(1) FROM entity');
-        
-        $this->assertEqual($c, 2);
-        
-        $c = $dbh->fetchOne('SELECT COUNT(1) FROM entity WHERE id = ?', array(1));
-        
-        $this->assertEqual($c, 1);
-    }
-    
-    public function testFetchAssoc() {
-
-    }
-    public function testFetchColumn() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-
-        $a = $dbh->fetchColumn('SELECT * FROM entity');
-
-        $this->assertEqual($a, array (
-                              0 => '1',
-                              1 => '2',
-                            ));
-
-        $a = $dbh->fetchColumn('SELECT * FROM entity WHERE id = ?', array(1));
-
-        $this->assertEqual($a, array (
-                              0 => '1',
-                            ));
-    }
-    public function testFetchArray() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-
-        $a = $dbh->fetchArray('SELECT * FROM entity');
-
-        $this->assertEqual($a, array (
-                              0 => '1',
-                              1 => 'zYne',
-                            ));
-
-        $a = $dbh->fetchArray('SELECT * FROM entity WHERE id = ?', array(1));
-
-        $this->assertEqual($a, array (
-                              0 => '1',
-                              1 => 'zYne',
-                            ));
-    }
-    public function testFetchRow() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-
-        $c = $dbh->fetchRow('SELECT * FROM entity');
-
-        $this->assertEqual($c, array (
-                              'id' => '1',
-                              'name' => 'zYne',
-                            ));
-                            
-        $c = $dbh->fetchRow('SELECT * FROM entity WHERE id = ?', array(1));
-        
-        $this->assertEqual($c, array (
-                              'id' => '1',
-                              'name' => 'zYne',
-                            ));
-    }
-    public function testFetchPairs() {
-                                   	
-    }
-    public function testAddValidEventListener() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-        
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_EventListener);
-        try {
-            $ret = $dbh->addListener(new Doctrine_DB_TestLogger());
-            $this->pass();
-            $this->assertTrue($ret instanceof Doctrine_DB2);
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_EventListener_Chain);
-        $this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_DB_TestLogger);
-        
-        try {
-            $ret = $dbh->addListener(new Doctrine_DB_TestValidListener());
-            $this->pass();
-            $this->assertTrue($ret instanceof Doctrine_DB2);
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_EventListener_Chain);
-        $this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_DB_TestLogger);
-        $this->assertTrue($dbh->getListener()->get(1) instanceof Doctrine_DB_TestValidListener);
-        
-        try {
-            $ret = $dbh->addListener(new Doctrine_DB_EventListener_Chain(), 'chain');
-            $this->pass();
-            $this->assertTrue($ret instanceof Doctrine_DB2);
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_EventListener_Chain);
-        $this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_DB_TestLogger);
-        $this->assertTrue($dbh->getListener()->get(1) instanceof Doctrine_DB_TestValidListener);
-        $this->assertTrue($dbh->getListener()->get('chain') instanceof Doctrine_DB_EventListener_Chain);
-        
-        // replacing
-
-        try {
-            $ret = $dbh->addListener(new Doctrine_DB_EventListener_Chain(), 'chain');
-            $this->pass();
-            $this->assertTrue($ret instanceof Doctrine_DB2);
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_EventListener_Chain);
-        $this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_DB_TestLogger);
-        $this->assertTrue($dbh->getListener()->get(1) instanceof Doctrine_DB_TestValidListener);
-        $this->assertTrue($dbh->getListener()->get('chain') instanceof Doctrine_DB_EventListener_Chain);
-    }
-    public function testListeningEventsWithSingleListener() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-        $dbh->connect();
-        $dbh->setListener(new Doctrine_DB_TestLogger());
-        $listener = $dbh->getListener();
-        $stmt = $dbh->prepare('INSERT INTO entity (id) VALUES(?)');
-
-        $this->assertEqual($listener->pop(), 'onPrepare');
-        $this->assertEqual($listener->pop(), 'onPrePrepare');
-        
-        $stmt->execute(array(1));
-
-        $this->assertEqual($listener->pop(), 'onExecute');
-        $this->assertEqual($listener->pop(), 'onPreExecute');
-        
-        $dbh->exec('DELETE FROM entity');
-
-        $this->assertEqual($listener->pop(), 'onExec');
-        $this->assertEqual($listener->pop(), 'onPreExec');
-        
-        $dbh->beginTransaction();
-
-        $this->assertEqual($listener->pop(), 'onBeginTransaction');
-        $this->assertEqual($listener->pop(), 'onPreBeginTransaction');
-
-        $dbh->query('INSERT INTO entity (id) VALUES (1)');
-
-        $dbh->commit();
-        
-        $this->assertEqual($listener->pop(), 'onCommit');
-        $this->assertEqual($listener->pop(), 'onPreCommit');
-        
-        $this->assertEqual($listener->pop(), 'onQuery');
-        $this->assertEqual($listener->pop(), 'onPreQuery');
-        
-        $dbh->query('DROP TABLE entity');
-    }
-    public function testListeningEventsWithListenerChain() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-        $dbh->connect();
-        $dbh->addListener(new Doctrine_DB_TestLogger());
-        $dbh->addListener(new Doctrine_DB_TestLogger());
-
-        $dbh->query('CREATE TABLE entity (id INT)');
-
-        $listener = $dbh->getListener()->get(0);
-        $listener2 = $dbh->getListener()->get(1);
-        $this->assertEqual($listener->pop(), 'onQuery');
-        $this->assertEqual($listener->pop(), 'onPreQuery');
-
-        $this->assertEqual($listener2->pop(), 'onQuery');
-        $this->assertEqual($listener2->pop(), 'onPreQuery');
-
-
-        $stmt = $dbh->prepare('INSERT INTO entity (id) VALUES(?)');
-
-        $this->assertEqual($listener->pop(), 'onPrepare');
-        $this->assertEqual($listener->pop(), 'onPrePrepare');
-
-        $this->assertEqual($listener2->pop(), 'onPrepare');
-        $this->assertEqual($listener2->pop(), 'onPrePrepare');
-
-        $stmt->execute(array(1));
-
-        $this->assertEqual($listener->pop(), 'onExecute');
-        $this->assertEqual($listener->pop(), 'onPreExecute');
-        
-        $this->assertEqual($listener2->pop(), 'onExecute');
-        $this->assertEqual($listener2->pop(), 'onPreExecute');
-        
-        $dbh->exec('DELETE FROM entity');
-
-        $this->assertEqual($listener->pop(), 'onExec');
-        $this->assertEqual($listener->pop(), 'onPreExec');
-
-        $this->assertEqual($listener2->pop(), 'onExec');
-        $this->assertEqual($listener2->pop(), 'onPreExec');
-
-        $dbh->beginTransaction();
-
-        $this->assertEqual($listener->pop(), 'onBeginTransaction');
-        $this->assertEqual($listener->pop(), 'onPreBeginTransaction');
-
-        $this->assertEqual($listener2->pop(), 'onBeginTransaction');
-        $this->assertEqual($listener2->pop(), 'onPreBeginTransaction');
-
-        $dbh->query('INSERT INTO entity (id) VALUES (1)');
-
-        $dbh->commit();
-
-        $this->assertEqual($listener->pop(), 'onCommit');
-        $this->assertEqual($listener->pop(), 'onPreCommit');
-        
-        $this->assertEqual($listener->pop(), 'onQuery');
-        $this->assertEqual($listener->pop(), 'onPreQuery');
-        
-        $dbh->query('DROP TABLE entity');
-    }
-    public function testSetValidEventListener() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-        try {
-            $dbh->setListener(new Doctrine_DB_TestLogger());
-            $this->pass();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_TestLogger);
-        try {
-            $dbh->setListener(new Doctrine_DB_TestValidListener());
-            $this->pass();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_TestValidListener);
-        try {
-            $dbh->setListener(new Doctrine_DB_EventListener_Chain());
-            $this->pass();
-
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_EventListener_Chain);
-        try {
-            $dbh->setListener(new Doctrine_DB_EventListener());
-            $this->pass();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->fail();
-        }
-        $this->assertTrue($dbh->getListener() instanceof Doctrine_DB_EventListener);
-    }
-    public function testSetInvalidEventListener() {
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-        try {
-            $dbh->setListener(new Doctrine_DB_TestInvalidListener());
-            $this->fail();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->pass();
-        }
-    }
-    public function testInvalidDSN() {
-        try {
-            $dbh = Doctrine_DB2::getConnection('');
-            $this->fail();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->pass();
-        }
-        try {
-            $dbh = Doctrine_DB2::getConnection('unknown');
-            $this->fail();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->pass();
-        }   
-        try {
-            $dbh = Doctrine_DB2::getConnection(0);
-            $this->fail();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->pass();
-        }
-    }
-    public function testInvalidScheme() {
-        try {
-            $dbh = Doctrine_DB2::getConnection('unknown://:memory:');
-            $this->fail();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->pass();
-        }
-    }
-    public function testInvalidHost() {
-        try {
-            $dbh = Doctrine_DB2::getConnection('mysql://user:password@');
-            $this->fail();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->pass();
-        }
-    }
-    public function testInvalidDatabase() {
-        try {
-            $dbh = Doctrine_DB2::getConnection('mysql://user:password@host/');
-            $this->fail();
-        } catch(Doctrine_DB_Exception $e) {
-            $this->pass();
-        }
-    }
-    public function testGetConnectionPdoLikeDSN() {
-        $dbh = Doctrine_DB2::getConnection('mysql:host=localhost;dbname=test', 'root', 'password');
-        $this->assertEqual($dbh->getDSN(), 'mysql:host=localhost;dbname=test');
-        $this->assertEqual($dbh->getUsername(), 'root');
-        $this->assertEqual($dbh->getPassword(), 'password');
-
-
-        $dbh = Doctrine_DB2::getConnection('sqlite::memory:');
-
-        $this->assertEqual($dbh->getDSN(), 'sqlite::memory:');
-        $this->assertEqual($dbh->getUsername(), null);
-        $this->assertEqual($dbh->getPassword(), null);
-    }
-    public function testDriverName() {
-
-    }
-
-    public function testGetConnectionWithPearLikeDSN() {
-        $dbh = Doctrine_DB2::getConnection('mysql://zYne:password@localhost/test');
-        $this->assertEqual($dbh->getDSN(), 'mysql:host=localhost;dbname=test');
-        $this->assertEqual($dbh->getUsername(), 'zYne');
-        $this->assertEqual($dbh->getPassword(), 'password');
-
-
-        $dbh = Doctrine_DB2::getConnection('sqlite://:memory:');
-
-        $this->assertEqual($dbh->getDSN(), 'sqlite::memory:');
-        $this->assertEqual($dbh->getUsername(), null);
-        $this->assertEqual($dbh->getPassword(), null);
-    }
-
-}
-?>
diff --git a/tests/DbProfilerTestCase.php b/tests/DbProfilerTestCase.php
new file mode 100644
index 000000000..36632dbf8
--- /dev/null
+++ b/tests/DbProfilerTestCase.php
@@ -0,0 +1,81 @@
+<?php
+class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
+    protected $dbh;
+    
+    protected $profiler;
+    public function prepareTables() {}
+    public function prepareData() {} 
+    
+    public function testQuery() {
+        $this->dbh = Doctrine_DB2::getConnection('sqlite::memory:');
+
+        $this->profiler = new Doctrine_DB_Profiler();
+
+        $this->dbh->setListener($this->profiler);
+
+        $this->dbh->query('CREATE TABLE test (id INT)');
+        
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'CREATE TABLE test (id INT)');
+        $this->assertTrue($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+        
+        $this->assertEqual($this->dbh->count(), 1);
+    }
+    public function testPrepareAndExecute() {
+
+        $stmt = $this->dbh->prepare('INSERT INTO test (id) VALUES (?)');
+
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
+        $this->assertFalse($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+
+        $stmt->execute(array(1));
+
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
+        $this->assertTrue($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+
+        $this->assertEqual($this->dbh->count(), 2);
+    }
+
+    public function testMultiplePrepareAndExecute() {
+
+        $stmt = $this->dbh->prepare('INSERT INTO test (id) VALUES (?)');
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
+        $this->assertFalse($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+
+        $stmt2 = $this->dbh->prepare('INSERT INTO test (id) VALUES (?)');
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
+        $this->assertFalse($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+
+        $stmt->execute(array(1));
+        $stmt2->execute(array(1));
+
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
+        $this->assertTrue($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+
+        $this->assertEqual($this->dbh->count(), 4);
+    }
+    /**
+    public function testExecuteStatementMultipleTimes() {
+        try {
+            $stmt = $this->dbh->prepare('INSERT INTO test (id) VALUES (?)');
+            $stmt->execute(array(1));
+            $stmt->execute(array(1));
+            $this->pass();
+        } catch(Doctrine_Db_Exception $e) {
+            $this->fail();
+        }
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
+        $this->assertTrue($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+
+        $this->assertEqual($this->profiler->lastQuery()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
+        $this->assertTrue($this->profiler->lastQuery()->hasEnded());
+        $this->assertTrue(is_numeric($this->profiler->lastQuery()->getElapsedSecs()));
+    }  */
+}
+?>
diff --git a/tests/QueryComponentAliasTestCase.php b/tests/QueryComponentAliasTestCase.php
index e6476e3fa..8fb74504e 100644
--- a/tests/QueryComponentAliasTestCase.php
+++ b/tests/QueryComponentAliasTestCase.php
@@ -13,7 +13,7 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($users->count(), 8);
         $this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
         $this->assertEqual($q->getQuery(), 
-        "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)");
+        "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)");
         $this->assertEqual($count, count($this->dbh));
     }
 
@@ -30,7 +30,7 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($users->count(), 8);
         $this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
         $this->assertEqual($q->getQuery(), 
-        "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber ON entity2.id = phonenumber.entity_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id LEFT JOIN phonenumber p ON e2.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
 
         $this->assertEqual(($count + 1), count($this->dbh));
     }
@@ -47,7 +47,7 @@ class Doctrine_Query_ComponentAlias_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($users->count(), 8);
         $this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
         $this->assertEqual($q->getQuery(), 
-        "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id, phonenumber2.id AS phonenumber2__id, phonenumber2.phonenumber AS phonenumber2__phonenumber, phonenumber2.entity_id AS phonenumber2__entity_id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber AS phonenumber2 ON entity2.id = phonenumber2.entity_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p2.id AS p2__id, p2.p AS p2__p, p2.entity_id AS p2__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id LEFT JOIN p AS p2 ON e2.id = p2.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $this->assertEqual($count, count($this->dbh));
     }
 }
diff --git a/tests/QueryConditionTestCase.php b/tests/QueryConditionTestCase.php
index 715a4d540..062626c00 100644
--- a/tests/QueryConditionTestCase.php
+++ b/tests/QueryConditionTestCase.php
@@ -15,7 +15,7 @@ class Doctrine_Query_Condition_TestCase extends Doctrine_UnitTestCase {
 
         $query->from("User(id)")->where("User.name LIKE 'z%' || User.name LIKE 's%'");
 
-        $sql = "SELECT entity.id AS entity__id FROM entity WHERE (entity.name LIKE 'z%' OR entity.name LIKE 's%') AND (entity.type = 0)";
+        $sql = "SELECT e.id AS e__id FROM entity e WHERE (e.name LIKE 'z%' OR e.name LIKE 's%') AND (e.type = 0)";
         $this->assertEqual($query->getQuery(), $sql);
 
         $query->where("(User.name LIKE 'z%') || (User.name LIKE 's%')");
@@ -32,7 +32,7 @@ class Doctrine_Query_Condition_TestCase extends Doctrine_UnitTestCase {
 
         $query->where("(User.name LIKE 'z%') || User.name LIKE 's%' && User.name LIKE 'a%'");
 
-        $sql = "SELECT entity.id AS entity__id FROM entity WHERE ((entity.name LIKE 'z%' OR entity.name LIKE 's%') AND entity.name LIKE 'a%') AND (entity.type = 0)";
+        $sql = "SELECT e.id AS e__id FROM entity e WHERE ((e.name LIKE 'z%' OR e.name LIKE 's%') AND e.name LIKE 'a%') AND (e.type = 0)";
 
         $this->assertEqual($query->getQuery(), $sql);
 
@@ -52,7 +52,7 @@ class Doctrine_Query_Condition_TestCase extends Doctrine_UnitTestCase {
 
         $query->from("User(id)")->where("User.name LIKE 'z%' || User.name LIKE 's%'");
 
-        $sql = "SELECT entity.id AS entity__id FROM entity WHERE (entity.name LIKE 'z%' OR entity.name LIKE 's%') AND (entity.type = 0)";
+        $sql = "SELECT e.id AS e__id FROM entity e WHERE (e.name LIKE 'z%' OR e.name LIKE 's%') AND (e.type = 0)";
         $this->assertEqual($query->getQuery(), $sql);
 
         $query->where("(User.name LIKE 'z%') OR (User.name LIKE 's%')");
@@ -69,7 +69,7 @@ class Doctrine_Query_Condition_TestCase extends Doctrine_UnitTestCase {
 
         $query->where("(User.name LIKE 'z%') OR User.name LIKE 's%' AND User.name LIKE 'a%'");
 
-        $sql = "SELECT entity.id AS entity__id FROM entity WHERE ((entity.name LIKE 'z%' OR entity.name LIKE 's%') AND entity.name LIKE 'a%') AND (entity.type = 0)";
+        $sql = "SELECT e.id AS e__id FROM entity e WHERE ((e.name LIKE 'z%' OR e.name LIKE 's%') AND e.name LIKE 'a%') AND (e.type = 0)";
 
         $this->assertEqual($query->getQuery(), $sql);
 
diff --git a/tests/QueryDeleteTestCase.php b/tests/QueryDeleteTestCase.php
index afda319d0..0616859eb 100644
--- a/tests/QueryDeleteTestCase.php
+++ b/tests/QueryDeleteTestCase.php
@@ -5,65 +5,65 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase {
 
         $q->parseQuery('DELETE FROM User');
 
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e WHERE (e.type = 0)');
 
         $q = new Doctrine_Query();
 
         $q->delete()->from('User');
         
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e WHERE (e.type = 0)');
     }
     public function testDeleteAll() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('DELETE FROM Entity');
 
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e');
         
         $q = new Doctrine_Query();
 
         $q->delete()->from('Entity');
         
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e');
     }
     public function testDeleteWithCondition() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('DELETE FROM Entity WHERE id = 3');
 
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE id = 3');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e WHERE id = 3');
         
         $q = new Doctrine_Query();
 
         $q->delete()->from('Entity')->where('id = 3');
         
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE id = 3');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e WHERE id = 3');
     }
     public function testDeleteWithLimit() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('DELETE FROM Entity LIMIT 20');
 
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 20');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e LIMIT 20');
         
         $q = new Doctrine_Query();
 
         $q->delete()->from('Entity')->limit(20);
         
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 20');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e LIMIT 20');
     }
     public function testDeleteWithLimitAndOffset() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('DELETE FROM Entity LIMIT 10 OFFSET 20');
 
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 10 OFFSET 20');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e LIMIT 10 OFFSET 20');
 
         $q = new Doctrine_Query();
 
         $q->delete()->from('Entity')->limit(10)->offset(20);
         
-        $this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 10 OFFSET 20');
+        $this->assertEqual($q->getQuery(), 'DELETE FROM entity e LIMIT 10 OFFSET 20');
     }
 }
 ?>
diff --git a/tests/QueryFromTestCase.php b/tests/QueryFromTestCase.php
index 9f8d177b2..702f767ac 100644
--- a/tests/QueryFromTestCase.php
+++ b/tests/QueryFromTestCase.php
@@ -5,7 +5,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u LEFT JOIN u.Group');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id FROM entity e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
 
         $users = $q->execute();
         
@@ -16,7 +16,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u JOIN u.Group');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id FROM entity e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
 
         $users = $q->execute();
         
@@ -27,7 +27,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u INNER JOIN u.Group');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id FROM entity INNER JOIN groupuser ON entity.id = groupuser.user_id INNER JOIN entity AS entity2 ON entity2.id = groupuser.group_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id FROM entity e INNER JOIN groupuser ON e.id = groupuser.user_id INNER JOIN entity e2 ON e2.id = groupuser.group_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
 
         $users = $q->execute();
         
@@ -38,7 +38,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $users = $q->execute();
 
         $this->assertEqual($users->count(), 8);
@@ -48,7 +48,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $users = $q->execute();
 
         $this->assertEqual($users->count(), 8);
@@ -58,7 +58,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u INNER JOIN u.Group INNER JOIN u.Phonenumber');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity INNER JOIN groupuser ON entity.id = groupuser.user_id INNER JOIN entity AS entity2 ON entity2.id = groupuser.group_id INNER JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e INNER JOIN groupuser ON e.id = groupuser.user_id INNER JOIN entity e2 ON e2.id = groupuser.group_id INNER JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $users = $q->execute();
 
         $this->assertEqual($users->count(), 1);
@@ -68,7 +68,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u INNER JOIN u.Group, u.Phonenumber');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity INNER JOIN groupuser ON entity.id = groupuser.user_id INNER JOIN entity AS entity2 ON entity2.id = groupuser.group_id INNER JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e INNER JOIN groupuser ON e.id = groupuser.user_id INNER JOIN entity e2 ON e2.id = groupuser.group_id INNER JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $users = $q->execute();
 
         $this->assertEqual($users->count(), 1);
@@ -78,7 +78,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase {
 
         $q->from('User u INNER JOIN u.Group LEFT JOIN u.Phonenumber');
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, entity2.id AS entity2__id, entity2.name AS entity2__name, entity2.loginname AS entity2__loginname, entity2.password AS entity2__password, entity2.type AS entity2__type, entity2.created AS entity2__created, entity2.updated AS entity2__updated, entity2.email_id AS entity2__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity INNER JOIN groupuser ON entity.id = groupuser.user_id INNER JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e INNER JOIN groupuser ON e.id = groupuser.user_id INNER JOIN entity e2 ON e2.id = groupuser.group_id LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $users = $q->execute();
 
         $this->assertEqual($users->count(), 1);
diff --git a/tests/QueryLimitTestCase.php b/tests/QueryLimitTestCase.php
index 5ea2a4428..3f4ecbab6 100644
--- a/tests/QueryLimitTestCase.php
+++ b/tests/QueryLimitTestCase.php
@@ -7,13 +7,14 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
 
         parent::prepareTables();
     }
+    /**
     public function testLimitWithOneToOneLeftJoin() {
         $q = new Doctrine_Query($this->connection);
         $q->from('User(id).Email')->limit(5);
 
         $users = $q->execute();
         $this->assertEqual($users->count(), 5);
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, email.id AS email__id, email.address AS email__address FROM entity LEFT JOIN email ON entity.email_id = email.id WHERE (entity.type = 0) LIMIT 5");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id, e2.address AS e2__address FROM entity e LEFT JOIN email e2 ON e.email_id = e2.id WHERE (e.type = 0) LIMIT 5");
 
     }
     public function testLimitWithOneToOneInnerJoin() {
@@ -22,13 +23,15 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
 
         $users = $q->execute();
         $this->assertEqual($users->count(), 5);
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, email.id AS email__id, email.address AS email__address FROM entity INNER JOIN email ON entity.email_id = email.id WHERE (entity.type = 0) LIMIT 5");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id, e2.address AS e2__address FROM entity e INNER JOIN email e2 ON e.email_id = e2.id WHERE (e.type = 0) LIMIT 5");
     }
     public function testLimitWithOneToManyLeftJoin() {
         $this->query->from("User(id).Phonenumber");
         $this->query->limit(5);
 
         $sql = $this->query->getQuery();
+        $this->assertEqual($this->query->getQuery(), 
+        'SELECT e.id AS e__id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE (e2.type = 0) LIMIT 5) AND (e.type = 0)');
 
         $users = $this->query->execute();
         $count = $this->dbh->count();
@@ -37,8 +40,6 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($count, $this->dbh->count());
         
 
-        $this->assertEqual($this->query->getQuery(), 
-        'SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT DISTINCT entity.id FROM entity WHERE (entity.type = 0) LIMIT 5) AND (entity.type = 0)');
 
 
         $this->query->offset(2);
@@ -53,20 +54,22 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
     public function testLimitWithOneToManyLeftJoinAndCondition() {
         $q = new Doctrine_Query($this->connection);
         $q->from("User(name)")->where("User.Phonenumber.phonenumber LIKE '%123%'")->limit(5);
+
         $users = $q->execute();
-        
+
+        $this->assertEqual($users->count(), 5);
+
         $this->assertEqual($users[0]->name, 'zYne');
         $this->assertEqual($users[1]->name, 'Arnold Schwarzenegger');
         $this->assertEqual($users[2]->name, 'Michael Caine');
         $this->assertEqual($users[3]->name, 'Sylvester Stallone');
         $this->assertEqual($users[4]->name, 'Jean Reno');
 
-        $this->assertEqual($users->count(), 5);
-
         $this->assertEqual($q->getQuery(),
-        "SELECT entity.id AS entity__id, entity.name AS entity__name FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT DISTINCT entity.id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE phonenumber.phonenumber LIKE '%123%' AND (entity.type = 0) LIMIT 5) AND phonenumber.phonenumber LIKE '%123%' AND (entity.type = 0)");
+        "SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 LEFT JOIN phonenumber p2 ON e2.id = p2.entity_id WHERE p2.phonenumber LIKE '%123%' AND (e2.type = 0) LIMIT 5) AND p.phonenumber LIKE '%123%' AND (e.type = 0)");
     }
 
+
     public function testLimitWithOneToManyLeftJoinAndOrderBy() {
         $q = new Doctrine_Query($this->connection);
         $q->from("User(name)")->where("User.Phonenumber.phonenumber LIKE '%123%'")->orderby("User.Email.address")->limit(5);
@@ -80,7 +83,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
 
         $this->assertEqual($users->count(), 5);
     }
-    
+
 
     public function testLimitWithOneToManyInnerJoin() {
         $this->query->select('u.id')->from("User u INNER JOIN u.Phonenumber");
@@ -105,8 +108,9 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($count, $this->dbh->count());
         
         $this->assertEqual($this->query->getQuery(),
-        'SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity INNER JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT DISTINCT entity.id FROM entity INNER JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0) LIMIT 5 OFFSET 2) AND (entity.type = 0)');
+        'SELECT e.id AS e__id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e INNER JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 INNER JOIN phonenumber p2 ON e2.id = p2.entity_id WHERE (e2.type = 0) LIMIT 5 OFFSET 2) AND (e.type = 0)');
     }
+
     public function testLimitWithPreparedQueries() {
         $q = new Doctrine_Query();
         $q->from("User(id).Phonenumber(id)");
@@ -120,7 +124,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($count, $this->dbh->count());
 
         $this->assertEqual($q->getQuery(),
-        'SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT DISTINCT entity.id FROM entity WHERE entity.name = ? AND (entity.type = 0) LIMIT 5) AND entity.name = ? AND (entity.type = 0)');
+        'SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE e2.name = ? AND (e2.type = 0) LIMIT 5) AND e.name = ? AND (e.type = 0)');
 
         $q = new Doctrine_Query();
         $q->from("User(id).Phonenumber(id)");
@@ -135,9 +139,11 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($count, $this->dbh->count());
 
         $this->assertEqual($q->getQuery(),
-        "SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT DISTINCT entity.id FROM entity WHERE (entity.name LIKE ? OR entity.name LIKE ?) AND (entity.type = 0) LIMIT 5) AND (entity.name LIKE ? OR entity.name LIKE ?) AND (entity.type = 0)");
+        "SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE (e2.name LIKE ? OR e2.name LIKE ?) AND (e2.type = 0) LIMIT 5) AND (e.name LIKE ? OR e.name LIKE ?) AND (e.type = 0)");
+
+    } 
+
 
-    }    
 
     public function testConnectionFlushing() {
         $q = new Doctrine_Query();
@@ -150,10 +156,13 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
         $this->connection->flush();
     }
 
+
     public function testLimitWithManyToManyColumnAggInheritanceLeftJoin() {
         $q = new Doctrine_Query($this->connection);
         $q->from("User.Group")->limit(5);
+
         $users = $q->execute();
+ 
 
         $this->assertEqual($users->count(), 5);
         
@@ -179,6 +188,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
         $q = new Doctrine_Query();
         $q->from("User")->where("User.Group.id = ?")->orderby("User.id ASC")->limit(5);
 
+
         $users = $q->execute(array($user->Group[1]->id));
 
         $this->assertEqual($users->count(), 3);
@@ -190,20 +200,22 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
 
         $this->assertEqual($users->count(), 3);
     }
+
     public function testLimitAttribute() {
-        $this->manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_ROWS);
+        $this->manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_RECORDS);
         
         $this->connection->clear();
         $q = new Doctrine_Query();
         $q->from("User")->where("User.Group.id = ?")->orderby("User.id DESC")->limit(5);
         $users = $q->execute(array(3));
-
+        print $q;
         $this->assertEqual($users->count(), 3);
         
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id WHERE entity2.id = ? AND (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL)) ORDER BY entity.id DESC LIMIT 5");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id WHERE e2.id = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL)) ORDER BY e.id DESC LIMIT 5");
 
         $this->manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_RECORDS);
     }
+        */
     public function testLimitWithNormalManyToMany() {
         $coll = new Doctrine_Collection($this->connection->getTable("Photo"));
         $tag = new Tag();
@@ -220,10 +232,12 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
 
         $q = new Doctrine_Query();
         $q->from("Photo")->where("Photo.Tag.id = ?")->orderby("Photo.id DESC")->limit(100);
+
         $photos = $q->execute(array(1));
         $this->assertEqual($photos->count(), 3);
         $this->assertEqual($q->getQuery(), 
-        "SELECT photo.id AS photo__id, photo.name AS photo__name FROM photo LEFT JOIN phototag ON photo.id = phototag.photo_id LEFT JOIN tag ON tag.id = phototag.tag_id WHERE photo.id IN (SELECT DISTINCT photo.id FROM photo LEFT JOIN phototag ON photo.id = phototag.photo_id LEFT JOIN tag ON tag.id = phototag.tag_id WHERE tag.id = ? ORDER BY photo.id DESC LIMIT 100) AND tag.id = ? ORDER BY photo.id DESC");
+        "SELECT p.id AS p__id, p.name AS p__name FROM photo p LEFT JOIN phototag ON p.id = phototag.photo_id LEFT JOIN tag t ON t.id = phototag.tag_id WHERE p.id IN (SELECT DISTINCT p2.id FROM photo p2 LEFT JOIN phototag ON p2.id = phototag.photo_id LEFT JOIN tag t2 ON t2.id = phototag.tag_id WHERE t2.id = ? ORDER BY p2.id DESC LIMIT 100) AND t2.id = ? ORDER BY p.id DESC");
     }
+
 }
 ?>
diff --git a/tests/QuerySelectTestCase.php b/tests/QuerySelectTestCase.php
index 90b1150f2..849968a38 100644
--- a/tests/QuerySelectTestCase.php
+++ b/tests/QuerySelectTestCase.php
@@ -7,21 +7,21 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
 
         $q->parseQuery('SELECT COUNT(u.id) FROM User u');
 
-        $this->assertEqual($q->getQuery(), 'SELECT COUNT(entity.id) AS entity__0 FROM entity WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT COUNT(e.id) AS e__0 FROM entity e WHERE (e.type = 0)');
     }
     public function testMultipleAggregateFunctions() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('SELECT MAX(u.id), MIN(u.name) FROM User u');
 
-        $this->assertEqual($q->getQuery(), 'SELECT MAX(entity.id) AS entity__0, MIN(entity.name) AS entity__1 FROM entity WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT MAX(e.id) AS e__0, MIN(e.name) AS e__1 FROM entity e WHERE (e.type = 0)');
     }
     public function testMultipleAggregateFunctionsWithMultipleComponents() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('SELECT MAX(u.id), MIN(u.name), COUNT(p.id) FROM User u, u.Phonenumber p');
 
-        $this->assertEqual($q->getQuery(), 'SELECT MAX(entity.id) AS entity__0, MIN(entity.name) AS entity__1, COUNT(phonenumber.id) AS phonenumber__2 FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT MAX(e.id) AS e__0, MIN(e.name) AS e__1, COUNT(p.id) AS p__2 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
     }
     public function testEmptySelectPart() {
         $q = new Doctrine_Query();
@@ -97,28 +97,28 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
 
         $q->parseQuery('SELECT u.* FROM User u');
 
-        $this->assertEqual($q->getQuery(), 'SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE (e.type = 0)');
     }
     public function testSingleComponentWithMultipleColumns() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('SELECT u.name, u.type FROM User u'); 
         
-        $this->assertEqual($q->getQuery(), 'SELECT entity.id AS entity__id, entity.name AS entity__name, entity.type AS entity__type FROM entity WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.type AS e__type FROM entity e WHERE (e.type = 0)');
     }
     public function testMultipleComponentsWithAsterisk() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('SELECT u.*, p.* FROM User u, u.Phonenumber p');
 
-        $this->assertEqual($q->getQuery(),'SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(),'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
     }
     public function testMultipleComponentsWithMultipleColumns() {
         $q = new Doctrine_Query();
 
         $q->parseQuery('SELECT u.id, u.name, p.id FROM User u, u.Phonenumber p');
 
-        $this->assertEqual($q->getQuery(),'SELECT entity.id AS entity__id, entity.name AS entity__name, phonenumber.id AS phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)');
+        $this->assertEqual($q->getQuery(),'SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
     }
 
 }
diff --git a/tests/QueryShortAliasesTestCase.php b/tests/QueryShortAliasesTestCase.php
new file mode 100644
index 000000000..8aced19a5
--- /dev/null
+++ b/tests/QueryShortAliasesTestCase.php
@@ -0,0 +1,22 @@
+<?php
+class Doctrine_Query_ShortAliases_TestCase extends Doctrine_UnitTestCase {
+    public function testShortAliasesWithSingleComponent() {
+        $q = new Doctrine_Query();
+        
+        $q->select('u.name')->from('User u');
+
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e WHERE (e.type = 0)');
+    }
+    public function testShortAliasesWithOneToManyLeftJoin() {
+        $q = new Doctrine_Query();
+        
+        $q->select('u.name, p.id')->from('User u LEFT JOIN u.Phonenumber p');
+
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
+
+        $users = $q->execute();
+        
+        $this->assertEqual($users->count(), 8);
+
+    }
+}
diff --git a/tests/QuerySubqueryTestCase.php b/tests/QuerySubqueryTestCase.php
index 60fe463f6..2d1771c70 100644
--- a/tests/QuerySubqueryTestCase.php
+++ b/tests/QuerySubqueryTestCase.php
@@ -5,7 +5,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase {
         $q->from('User')->where("User.id NOT IN (FROM User(id) WHERE User.name = 'zYne')");
 
         $this->assertEqual($q->getQuery(),
-        "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity WHERE entity.id NOT IN (SELECT entity.id AS entity__id FROM entity WHERE entity.name = 'zYne' AND (entity.type = 0)) AND (entity.type = 0)");
+        "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE e.id NOT IN (SELECT e.id AS e__id FROM entity e WHERE e.name = 'zYne' AND (e.type = 0)) AND (e.type = 0)");
 
         $users = $q->execute();
 
diff --git a/tests/QueryTestCase.php b/tests/QueryTestCase.php
index 36c7a473c..f3887d8b7 100644
--- a/tests/QueryTestCase.php
+++ b/tests/QueryTestCase.php
@@ -29,6 +29,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         parent::prepareTables();
         $this->connection->clear();
     }
+    /**
     public function testValidLazyPropertyFetching() {
         $q = new Doctrine_Query($this->connection);
         $q->from("User(id, name)");
@@ -76,7 +77,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         
         $q->parseQuery($dql);
 
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity WHERE entity.id = ? AND (entity.type = 0)");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e e WHERE e.id = ? AND (e.type = 0)");
     }
     public function testUnknownFunction() {
         $q = new Doctrine_Query();
@@ -108,7 +109,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
 
         $coll = $q->execute(array('123 123'));
 
-        $this->assertEqual($q->getQuery(), 'SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber = ?) AND (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e e LEFT JOIN phonenumber ON e.id = p.entity_id WHERE e.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber = ?) AND (e.type = 0)');
 
         $this->assertEqual($coll->count(), 3);
         $this->assertEqual($coll[0]->name, 'zYne');
@@ -126,7 +127,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
 
         $coll = $q->execute(array('%123%', '%5%'));
 
-        $this->assertEqual($q->getQuery(), 'SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber LIKE ?) AND entity.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber LIKE ?) AND (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e e LEFT JOIN phonenumber ON e.id = p.entity_id WHERE e.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber LIKE ?) AND e.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber LIKE ?) AND (e.type = 0)');
 
         $this->assertEqual($coll->count(), 3);
         $this->assertEqual($coll[0]->name, 'Arnold Schwarzenegger');
@@ -144,7 +145,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
 
         $coll = $q->execute(array('123%'));
 
-        $this->assertEqual($q->getQuery(), 'SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber LIKE ?) AND (entity.type = 0)');
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e e LEFT JOIN phonenumber ON e.id = p.entity_id WHERE e.id IN (SELECT entity_id FROM phonenumber WHERE phonenumber LIKE ?) AND (e.type = 0)');
 
         $this->assertEqual($coll->count(), 5);
         $this->assertEqual($coll[0]->name, 'zYne');
@@ -171,7 +172,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
                 ->where("EnumTest.status = 'open'")
                 ->execute();
         
-        $this->assertEqual($q->getQuery(), 'SELECT enum_test.id AS enum_test__id, enum_test.status AS enum_test__status FROM enum_test WHERE enum_test.status = 0');
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.status AS e__status FROM enum_test e WHERE e.status = 0');
         $this->assertEqual($coll->count(), 1);
         
         $q = new Doctrine_Query;
@@ -180,7 +181,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
                 ->where("EnumTest.status = 'verified'")
                 ->execute();
         
-        $this->assertEqual($q->getQuery(), 'SELECT enum_test.id AS enum_test__id, enum_test.status AS enum_test__status FROM enum_test WHERE enum_test.status = 1');
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.status AS e__status FROM enum_test e WHERE e.status = 1');
         $this->assertEqual($coll->count(), 1);
     }
 
@@ -188,7 +189,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
 
         $query = new Doctrine_Query($this->connection);
 
-        $query->from('User-l:Group-l');
+        $query->from('User u INNER JOIN u.Group g');
 
         $users = $query->execute();
         $this->assertEqual($users->count(), 1);
@@ -216,25 +217,34 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($users[2]->type, 0);
 
         $this->connection->flush();
-
+    }
+    public function testManyToManyFetchingWithColumnAggregationInheritance2() {
+        $query = new Doctrine_Query();
         $users = $query->query("FROM User-b WHERE User.Group.name = 'Action Actors'");
 
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id WHERE entity2.name = 'Action Actors' AND (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        "SELECT e.id AS e__id FROM entity e e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id WHERE e2.name = 'Action Actors' AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $this->assertTrue($users instanceof Doctrine_Collection);
         $this->assertEqual($users->count(),1);
 
-        $this->assertEqual(count($this->dbh->query($query->getQuery())->fetchAll()),1);
-
+        $this->assertEqual(count($this->dbh->query($query->getQuery())->fetchAll()), 1);
+    }
+    public function testManyToManyFetchingWithColumnAggregationInheritance3() {
+        $query = new Doctrine_Query();
         $users = $query->query("FROM User-b WHERE User.Group.Phonenumber.phonenumber LIKE '123 123'");
 
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id FROM entity LEFT JOIN groupuser ON entity.id = groupuser.user_id LEFT JOIN entity AS entity2 ON entity2.id = groupuser.group_id LEFT JOIN phonenumber ON entity2.id = phonenumber.entity_id WHERE phonenumber.phonenumber LIKE '123 123' AND (entity.type = 0 AND (entity2.type = 1 OR entity2.type IS NULL))");
+        "SELECT e.id AS e__id FROM entity e e LEFT JOIN groupuser ON e.id = groupuser.user_id LEFT JOIN entity e2 ON e2.id = groupuser.group_id LEFT JOIN phonenumber ON e2.id = p.entity_id WHERE p.phonenumber LIKE '123 123' AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))");
         $this->assertTrue($users instanceof Doctrine_Collection);
         $this->assertEqual($users->count(),1);
-
+    }
+    */
+    public function testManyToManyFetchingWithColumnAggregationInheritance4() {
         $query = new Doctrine_Query();
-        $users = $query->query("FROM User.Group WHERE User.Group.name = 'Action Actors'");
+        $query->parseQuery("FROM User.Group WHERE User.Group.name = 'Action Actors'");
+
+        $users = $query->execute();
+
         $this->assertEqual($users->count(), 1);
         $count = $this->dbh->count();
 
@@ -245,15 +255,15 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual($users[0]->Group[0]->name, 'Action Actors');
         $this->assertEqual($count, $this->dbh->count());
     }
-
+    /**
     public function testSelectingAggregateValues() {
 
         $q = new Doctrine_Query();
         $q->from("User(COUNT(1), MAX(name))");
         $array = $q->execute();
         $this->assertTrue(is_array($array));
-        $this->assertEqual($array, array(array('COUNT(1)' => '8', 'MAX(entity.name)' => 'zYne')));
-        $this->assertEqual($q->getQuery(), "SELECT COUNT(1), MAX(entity.name) FROM entity WHERE (entity.type = 0)");
+        $this->assertEqual($array, array(array('COUNT(1)' => '8', 'MAX(e.name)' => 'zYne')));
+        $this->assertEqual($q->getQuery(), "SELECT COUNT(1), MAX(e.name) FROM entity e e WHERE (e.type = 0)");
 
         $q = new Doctrine_Query();
         $q->from("Phonenumber(COUNT(1))");
@@ -261,29 +271,28 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $array = $q->execute();
         $this->assertTrue(is_array($array));
         $this->assertEqual($array, array(array('COUNT(1)' => '15')));
-        $this->assertEqual($q->getQuery(), "SELECT COUNT(1) FROM phonenumber");
+        $this->assertEqual($q->getQuery(), "SELECT COUNT(1) FROM phonenumber p");
 
         $q = new Doctrine_Query();
         $q->from("User.Phonenumber(COUNT(id))");
         $array = $q->execute();
         $this->assertTrue(is_array($array));
 
-        $this->assertEqual($array[0]['COUNT(phonenumber.id)'], 14);
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id, COUNT(phonenumber.id) FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)");
+        $this->assertEqual($array[0]['COUNT(p.id)'], 14);
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, COUNT(p.id) FROM entity e e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)");
 
         $q = new Doctrine_Query();
-        $q->from("User(MAX(id)).Email(MIN(address))");
-        $array = $q->execute();
-        $this->assertTrue(is_array($array));
-        $this->assertEqual($array[0]['MAX(entity.id)'], 11);
-        $this->assertEqual($array[0]['MIN(email.address)'], 'arnold@example.com');
+        $q->select('MAX(u.id), MIN(e.address)')->from("User u INNER JOIN u.Email e");
+        $coll = $q->execute();
+        $this->assertEqual($coll->getAggregateValue('MAX(e.id)'), 11);
+        $this->assertEqual($coll['MIN(email.address)'], 'arnold@example.com');
 
         $q = new Doctrine_Query();
         $q->from("User(MAX(id)).Email(MIN(address)), User.Phonenumber(COUNT(1))");
         $array = $q->execute();
         $this->assertTrue(is_array($array));
 
-        $this->assertEqual($array[0]['MAX(entity.id)'], 11);
+        $this->assertEqual($array[0]['MAX(e.id)'], 11);
         $this->assertEqual($array[0]['MIN(email.address)'], 'arnold@example.com');
         $this->assertEqual($array[0]['COUNT(1)'], 14);
 
@@ -295,6 +304,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         //$this->assertEqual(count($coll), 8);
 
     }
+    */
 
 
     public function testMultipleFetching() {
@@ -341,18 +351,18 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
     public function testGetPath() {
         $this->query->from("User.Group.Email");
         
-        $this->assertEqual($this->query->getTableAlias("User"),  "entity");
-        $this->assertEqual($this->query->getTableAlias("User.Group"), "entity2");
+        $this->assertEqual($this->query->getTableAlias("User"),  "e");
+        $this->assertEqual($this->query->getTableAlias("User.Group"), "e2");
 
 
         $this->query->from("Task.Subtask.Subtask");
-        $this->assertEqual($this->query->getTableAlias("Task"), "task");
-        $this->assertEqual($this->query->getTableAlias("Task.Subtask"), "task2");
-        $this->assertEqual($this->query->getTableAlias("Task.Subtask.Subtask"), "task3");
+        $this->assertEqual($this->query->getTableAlias("Task"), "t");
+        $this->assertEqual($this->query->getTableAlias("Task.Subtask"), "t2");
+        $this->assertEqual($this->query->getTableAlias("Task.Subtask.Subtask"), "t3");
         
 
         $this->assertEqual($this->query->getQuery(), 
-        "SELECT task.id AS task__id, task.name AS task__name, task.parent_id AS task__parent_id, task2.id AS task2__id, task2.name AS task2__name, task2.parent_id AS task2__parent_id, task3.id AS task3__id, task3.name AS task3__name, task3.parent_id AS task3__parent_id FROM task LEFT JOIN task AS task2 ON task.id = task2.parent_id LEFT JOIN task AS task3 ON task2.id = task3.parent_id");
+        "SELECT t.id AS t__id, t.name AS t__name, t.parent_id AS t__parent_id, t2.id AS t2__id, t2.name AS t2__name, t2.parent_id AS t2__parent_id, t3.id AS t3__id, t3.name AS t3__name, t3.parent_id AS t3__parent_id FROM task t LEFT JOIN task t2 ON t.id = t2.parent_id LEFT JOIN task t3 ON t2.id = t3.parent_id");
     }
 
     public function testMultiComponentFetching2() {
@@ -908,19 +918,19 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $table = $this->connection->getTable("Forum_Thread")->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_LAZY);
         $q->from("Forum_Board.Threads");
 
-        $this->assertEqual($q->getQuery(), "SELECT forum__board.id AS forum__board__id, forum__thread.id AS forum__thread__id FROM forum__board LEFT JOIN forum__thread ON forum__board.id = forum__thread.board_id");
+        $this->assertEqual($q->getQuery(), "SELECT f.id AS f__id, f2.id AS f2__id FROM forum__board f LEFT JOIN forum__thread f2 ON f.id = f2.board_id");
         $coll = $q->execute();
         $this->assertEqual($coll->count(), 1);
 
 
 
         $q->from("Forum_Board-l.Threads-l");
-        $this->assertEqual($q->getQuery(), "SELECT forum__board.id AS forum__board__id, forum__thread.id AS forum__thread__id FROM forum__board LEFT JOIN forum__thread ON forum__board.id = forum__thread.board_id");
+        $this->assertEqual($q->getQuery(), "SELECT f.id AS f__id, f2.id AS f2__id FROM forum__board f LEFT JOIN forum__thread f2 ON f.id = f2.board_id");
 
         //$this->connection->clear();
 
         $q->from("Forum_Board-l.Threads-l.Entries-l");
-        $this->assertEqual($q->getQuery(), "SELECT forum__board.id AS forum__board__id, forum__thread.id AS forum__thread__id, forum__entry.id AS forum__entry__id FROM forum__board LEFT JOIN forum__thread ON forum__board.id = forum__thread.board_id LEFT JOIN forum__entry ON forum__thread.id = forum__entry.thread_id");
+        $this->assertEqual($q->getQuery(), "SELECT f.id AS f__id, f2.id AS f2__id, f3.id AS f3__id FROM forum__board f LEFT JOIN forum__thread f2 ON f.id = f2.board_id LEFT JOIN forum__entry f3 ON f2.id = f3.thread_id");
         $boards = $q->execute();
         $this->assertEqual($boards->count(), 1);
         $count = count($this->dbh);
@@ -960,23 +970,23 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $query = $query->from("User-l");
 
         $this->assertTrue($query instanceof Doctrine_Query);
-        $this->assertEqual($query->get("from"), array("entity" => true));
+        $this->assertEqual($query->get("from"), "entity e");
 
         $query = $query->orderby("User.name");
         $this->assertTrue($query instanceof Doctrine_Query);
-        $this->assertEqual($query->get("orderby"), array("entity.name"));
+        $this->assertEqual($query->get("orderby"), array("e.name"));
 
         $query = $query->orderby("User.created");
         $this->assertTrue($query instanceof Doctrine_Query);
-        $this->assertEqual($query->get("orderby"), array("entity.created"));
+        $this->assertEqual($query->get("orderby"), array("e.created"));
 
         $query = $query->where("User.name LIKE 'zYne%'");
         $this->assertTrue($query instanceof Doctrine_Query);
-        $this->assertEqual($query->get("where"), array("entity.name LIKE 'zYne%'"));
+        $this->assertEqual($query->get("where"), array("e.name LIKE 'zYne%'"));
 
         $query = $query->where("User.name LIKE 'Arnold%'");
         $this->assertTrue($query instanceof Doctrine_Query);
-        $this->assertEqual($query->get("where"), array("entity.name LIKE 'Arnold%'"));
+        $this->assertEqual($query->get("where"), array("e.name LIKE 'Arnold%'"));
 
         $query = $query->limit(5);
         $this->assertTrue($query instanceof Doctrine_Query);
@@ -1024,7 +1034,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $users = $query->execute();
 
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id FROM entity LEFT JOIN email ON entity.email_id = email.id WHERE (entity.type = 0) ORDER BY entity.name ASC, email.address");
+        "SELECT e.id AS e__id FROM entity e LEFT JOIN email e2 ON e.email_id = e2.id WHERE (e.type = 0) ORDER BY e.name ASC, e2.address");
         $this->assertEqual($users->count(),8);
         $this->assertTrue($users[0]->name == "Arnold Schwarzenegger");
     }
@@ -1032,7 +1042,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $query = new Doctrine_Query($this->connection);
         $users = $query->query("FROM User-b");
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id FROM entity WHERE (entity.type = 0)");
+        "SELECT e.id AS e__id FROM entity e WHERE (e.type = 0)");
 
         $this->assertEqual($users[0]->name, "zYne");
         $this->assertTrue($users instanceof Doctrine_Collection_Batch);
@@ -1041,7 +1051,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $query = new Doctrine_Query($this->connection);
         $users = $query->query("FROM User-l");
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id FROM entity WHERE (entity.type = 0)");
+        "SELECT e.id AS e__id FROM entity e WHERE (e.type = 0)");
 
         $this->assertEqual($users[0]->name, "zYne");
         $this->assertTrue($users instanceof Doctrine_Collection_Lazy);
@@ -1049,7 +1059,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
     }
 
 
-    function testFetchingWithCollectionExpanding() {
+    public function testFetchingWithCollectionExpanding() {
         // DYNAMIC COLLECTION EXPANDING
         $query = new Doctrine_Query($this->connection);
 
@@ -1079,7 +1089,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
 
         $users = $query->query("FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'");
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE phonenumber.phonenumber LIKE '%123%' AND (entity.type = 0)");
+        "SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE p.phonenumber LIKE '%123%' AND (e.type = 0)");
 
         $count = $this->connection->getDBH()->count();
 
@@ -1105,7 +1115,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
 
         $users = $query->query("FROM User-i");
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id, entity.name AS entity__name, entity.loginname AS entity__loginname, entity.password AS entity__password, entity.type AS entity__type, entity.created AS entity__created, entity.updated AS entity__updated, entity.email_id AS entity__email_id FROM entity WHERE (entity.type = 0)");
+        "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE (e.type = 0)");
 
         $count = $this->connection->getDBH()->count();
         $this->assertEqual($users[0]->name, "zYne");
@@ -1122,7 +1132,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
 
         $users = $query->query("FROM User-b.Phonenumber-b");
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0)");
+        "SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)");
 
         $this->assertEqual($users->count(),8);
 
@@ -1139,29 +1149,29 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
         $users = $query->query("FROM User-l:Email-b");
 
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id, email.id AS email__id FROM entity INNER JOIN email ON entity.email_id = email.id WHERE (entity.type = 0)");
+        "SELECT e.id AS e__id, e2.id AS e2__id FROM entity e INNER JOIN email e2 ON e.email_id = e2.id WHERE (e.type = 0)");
 
         $this->assertEqual($users->count(),8);
 
         $users = $query->query("FROM Email-b WHERE Email.address LIKE '%@example%'");
 
         $this->assertEqual($query->getQuery(),
-        "SELECT email.id AS email__id FROM email WHERE email.address LIKE '%@example%'");
+        "SELECT e.id AS e__id FROM email e WHERE e.address LIKE '%@example%'");
         $this->assertEqual($users->count(),8);
 
         $users = $query->query("FROM User-b WHERE User.name LIKE '%Jack%'");
-        $this->assertEqual($query->getQuery(), "SELECT entity.id AS entity__id FROM entity WHERE entity.name LIKE '%Jack%' AND (entity.type = 0)");
+        $this->assertEqual($query->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name LIKE '%Jack%' AND (e.type = 0)");
         $this->assertEqual($users->count(),0);
 
 
         $users = $query->query("FROM User-b WHERE User.Phonenumber.phonenumber LIKE '%123%'");
         $this->assertEqual(trim($query->getQuery()),
-        "SELECT entity.id AS entity__id FROM entity LEFT JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE phonenumber.phonenumber LIKE '%123%' AND (entity.type = 0)");
+        "SELECT e.id AS e__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE p.phonenumber LIKE '%123%' AND (e.type = 0)");
         $this->assertEqual($users->count(),5);
 
 
         //$values = $query->query("SELECT COUNT(User.name) AS users, MAX(User.name) AS max FROM User");
-        //$this->assertEqual(trim($query->getQuery()),"SELECT COUNT(entity.name) AS users, MAX(entity.name) AS max FROM entity WHERE (entity.type = 0)");
+        //$this->assertEqual(trim($query->getQuery()),"SELECT COUNT(e.name) AS users, MAX(e.name) AS max FROM entity e e WHERE (e.type = 0)");
         //$this->assertTrue(is_array($values));
         //$this->assertTrue(isset($values['users']));
         //$this->assertTrue(isset($values['max']));
diff --git a/tests/QueryUpdateTestCase.php b/tests/QueryUpdateTestCase.php
index 611208b0c..956d22063 100644
--- a/tests/QueryUpdateTestCase.php
+++ b/tests/QueryUpdateTestCase.php
@@ -5,13 +5,13 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase {
 
         $q->parseQuery("UPDATE User u SET u.name = 'someone'");
 
-        $this->assertEqual($q->getQuery(), "UPDATE entity SET entity.name = 'someone' WHERE (entity.type = 0)");
+        $this->assertEqual($q->getQuery(), "UPDATE entity SET e.name = 'someone' WHERE (e.type = 0)");
 
         $q = new Doctrine_Query();
 
         $q->update('User u')->set('u.name', 'someone');
 
-        $this->assertEqual($q->getQuery(), "UPDATE entity SET entity.name = 'someone' WHERE (entity.type = 0)");
+        $this->assertEqual($q->getQuery(), "UPDATE entity SET e.name = 'someone' WHERE (e.type = 0)");
     }
 }
 ?>
diff --git a/tests/QueryWhereTestCase.php b/tests/QueryWhereTestCase.php
index df62e0c43..12d97f9fd 100644
--- a/tests/QueryWhereTestCase.php
+++ b/tests/QueryWhereTestCase.php
@@ -80,7 +80,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
         $users = $q->execute();
         $this->assertEqual($users->count(), 2);
         $this->assertEqual($users[0]->name, 'someone');
-        $this->assertEqual($users[1]->name, 'someone.2');  
+        $this->assertEqual($users[1]->name, 'someone.2');
     }
     public function testComponentAliases() {
         $q = new Doctrine_Query();
@@ -118,7 +118,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
         $users = $q->execute();
         $this->assertEqual($users->count(), 1);
         
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id FROM entity WHERE entity.name = 'someone' AND (entity.type = 0)");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'someone' AND (e.type = 0)");
     }
     public function testOperatorWithNoTrailingSpaces2() {
         $q = new Doctrine_Query();
@@ -128,7 +128,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
         $users = $q->execute();
         $this->assertEqual($users->count(), 0);
         
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id FROM entity WHERE entity.name = 'foo.bar' AND (entity.type = 0)");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'foo.bar' AND (e.type = 0)");
     }
     public function testOperatorWithSingleTrailingSpace() {
         $q = new Doctrine_Query();
@@ -138,7 +138,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
         $users = $q->execute();
         $this->assertEqual($users->count(), 0);
         
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id FROM entity WHERE entity.name = 'foo.bar' AND (entity.type = 0)");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'foo.bar' AND (e.type = 0)");
     }
     public function testOperatorWithSingleTrailingSpace2() {
         $q = new Doctrine_Query();
@@ -148,7 +148,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase {
         $users = $q->execute();
         $this->assertEqual($users->count(), 0);
         
-        $this->assertEqual($q->getQuery(), "SELECT entity.id AS entity__id FROM entity WHERE entity.name = 'foo.bar' AND (entity.type = 0)");
+        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE e.name = 'foo.bar' AND (e.type = 0)");
     }
 
 }
diff --git a/tests/run.php b/tests/run.php
index 4cc648530..db89c457b 100644
--- a/tests/run.php
+++ b/tests/run.php
@@ -39,6 +39,7 @@ require_once('QueryConditionTestCase.php');
 require_once('QueryComponentAliasTestCase.php');
 require_once('QuerySubqueryTestCase.php');
 require_once('QuerySelectTestCase.php');
+require_once('QueryShortAliasesTestCase.php');
 require_once('QueryDeleteTestCase.php');
 require_once('QueryUpdateTestCase.php');
 
@@ -47,7 +48,9 @@ require_once('RelationTestCase.php');
 require_once('RelationManyToManyTestCase.php');
 
 
-require_once('DBTestCase.php');
+require_once('DbTestCase.php');
+require_once('DbProfilerTestCase.php');
+
 require_once('SchemaTestCase.php');
 require_once('ImportTestCase.php');
 require_once('BooleanTestCase.php');
@@ -64,8 +67,17 @@ print '<pre>';
 
 $test = new GroupTest('Doctrine Framework Unit Tests');
 
+
+//$test->addTestCase(new Doctrine_Db_Profiler_TestCase());
+
+//$test->addTestCase(new Doctrine_DB_TestCase());
+
+$test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
+
 $test->addTestCase(new Doctrine_Record_TestCase());
 
+$test->addTestCase(new Doctrine_ConnectionTestCase());
+
 $test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
 
 $test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
@@ -74,21 +86,17 @@ $test->addTestCase(new Doctrine_Relation_TestCase());
 
 $test->addTestCase(new Doctrine_Record_State_TestCase());
 
-$test->addTestCase(new Doctrine_Import_TestCase());
+//$test->addTestCase(new Doctrine_Import_TestCase());
 
 $test->addTestCase(new Doctrine_SchemaTestCase());
 
 $test->addTestCase(new Doctrine_ValidatorTestCase());
 
-$test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
 
 $test->addTestCase(new Doctrine_EventListenerTestCase());
 
 $test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
 
-$test->addTestCase(new Doctrine_ConnectionTestCase());
-
-$test->addTestCase(new Doctrine_DB_TestCase());
 
 $test->addTestCase(new Doctrine_AccessTestCase());
 
@@ -136,8 +144,12 @@ $test->addTestCase(new Doctrine_Query_ComponentAlias_TestCase());
 
 $test->addTestCase(new Doctrine_Query_Subquery_TestCase());
 
+$test->addTestCase(new Doctrine_EnumTestCase());
+
 $test->addTestCase(new Doctrine_Query_TestCase());
 
+$test->addTestCase(new Doctrine_Query_ShortAliases_TestCase());
+
 $test->addTestCase(new Doctrine_Query_Where_TestCase());
 
 $test->addTestCase(new Doctrine_Query_From_TestCase());
@@ -150,7 +162,7 @@ $test->addTestCase(new Doctrine_Query_Update_TestCase());
 
 $test->addTestCase(new Doctrine_Query_Limit_TestCase());
 
-$test->addTestCase(new Doctrine_EnumTestCase());
+
 
 //$test->addTestCase(new Doctrine_Cache_FileTestCase());
 //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());