$q->select('u.id')->from('User u')->where('u.name IN (SELECT u2.name FROM User u2 WHERE u2.id = u.id)');
$this->assertEqual($q->getSql(),'SELECT e.id AS e__id FROM entity e WHERE e.name IN (SELECT e2.name AS e2__name FROM entity e2 WHERE e2.id = e.id AND (e.type = 0 AND (e2.type = 0 OR e2.type IS NULL))) AND (e.type = 0)');