Permalink
Browse files

Don't add separator if not prefixing columns

When not prefixing columns with the table name
don't add the platform's identifier separator.

Fixes #2599
  • Loading branch information...
1 parent 17c7687 commit ab1194852f111571a7da686630118112234b01a6 @robertbasic robertbasic committed Oct 9, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 library/Zend/Db/Sql/Select.php
  2. +14 −0 tests/ZendTest/Db/Sql/SelectTest.php
@@ -533,7 +533,7 @@ protected function processSelect(PlatformInterface $platform, Adapter $adapter =
$fromTable = ($this->prefixColumnsWithTable) ? $table : '';
}
- $fromTable .= $platform->getIdentifierSeparator();
+ $fromTable .= ($this->prefixColumnsWithTable) ? $platform->getIdentifierSeparator() : '';
// process table columns
$columns = array();
@@ -470,6 +470,20 @@ public function testProcessMethods(Select $select, $unused, $unused2, $unused3,
}
}
+ /**
+ * @autor robertbasic
+ * @group issue2599
+ * @testdox unit test: Not prefixing columns with table will create a valid query
+ */
+ public function testNotPrefixingColumnsWithTableNameCreatesValidQuery()
+ {
+ $select = new Select;
+ $select->from('foo')
+ ->columns(array('bar'), false);
+
+ $this->assertEquals('SELECT "bar" AS "bar" FROM "foo"', $select->getSqlString());
+ }
+
public function providerData()
{
// basic table

0 comments on commit ab11948

Please sign in to comment.