ZF2-221: Joins in Zend\Db\Sql\Select should allow providing aliased field names


The join() method in Zend\Db\Sql\Select.php doesn't allow passing an aliased field name in the $columns parameter. The array should allow passing the fields as an associative array, for example array('aliasedName' => 'fieldName') ... It's very important in complex joins where some field names are identical and clashing.



--- a/tests/Zend/Db/Sql/SelectTest.php
+++ b/tests/Zend/Db/Sql/SelectTest.php
@@ -305,6 +305,11 @@ class SelectTest extends \PHPUnit_Framework_TestCase
         $select9 = new Select;
         $select9->from('foo')->join('zac', 'm = n', array('bar', 'baz'));
         $sql9 = 'SELECT "foo".*, "zac"."bar", "zac"."baz" FROM "foo" INNER JOIN "zac" ON "m" = "n"';
+        // join with column aliases
+        $select9a = new Select;
+        $select9a->from('foo')->join('zac', 'm = n', array('bar', 'bat' => 'baz'));
+        $sql9a = 'SELECT "foo".*, "zac"."bar", "zac"."baz" AS "bat" FROM "foo" INNER JOIN "zac" ON "m" = "n"';

This is fixed in latest master, please try it.

Works fine. Thanks.