Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Hotfix for issue #4069 #4070

Merged
merged 2 commits into from

3 participants

@tux-rampage

Oracle renders from table with alias incorrectly with "AS".

  • Modified implementation of Sql\Select and oracle specific SelectDecorator to reflect the correct behavior
  • Added UnitTest to test this implementation

This will resolve #4069

tux-rampage added some commits
@tux-rampage tux-rampage [+BUGFIX] Fixed issue #4069
Oracle renders from table with alias incorrectly with "AS".
Modified implementation of Sql\Select and oracle specific
SelectDecorator to reflect the correct behavior
f9a3dd7
@tux-rampage tux-rampage [~TASK] Corrected @covers annotation in unit test
Corrected incorrect @covers annotation in oracle specific
SelectDecoratorTest
fd53e6e
@tux-rampage

Is there anything that would prevent merging this fix?

@weierophinney

@ralphschindler ping -- can you review and merge, please?

@ralphschindler ralphschindler referenced this pull request from a commit
@ralphschindler ralphschindler PR #4070
Merge branch 'hotfix/4069' of git://github.com/tux-rampage/zf2 into tux-rampage-hotfix/4069
b7b001f
@ralphschindler ralphschindler referenced this pull request from a commit
@ralphschindler ralphschindler PR #4070
Merge branch 'tux-rampage-hotfix/4069'
b0beef4
@ralphschindler ralphschindler merged commit fd53e6e into zendframework:master
@ralphschindler ralphschindler referenced this pull request from a commit
@ralphschindler ralphschindler Forward #4070
Merge branch 'tux-rampage-hotfix/4069' into develop
c0d02be
@tux-rampage tux-rampage deleted the tux-rampage:hotfix/4069 branch
@ghost Unknown referenced this pull request from a commit
@ralphschindler ralphschindler PR #4070
Merge branch 'hotfix/4069' of git://github.com/tux-rampage/zf2 into tux-rampage-hotfix/4069
7205a41
@ghost Unknown referenced this pull request from a commit
@ralphschindler ralphschindler PR #4070
Merge branch 'tux-rampage-hotfix/4069'
00e4499
@ghost Unknown referenced this pull request from a commit
@ralphschindler ralphschindler Forward #4070
Merge branch 'tux-rampage-hotfix/4069' into develop
e21430a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 18, 2013
  1. @tux-rampage

    [+BUGFIX] Fixed issue #4069

    tux-rampage authored
    Oracle renders from table with alias incorrectly with "AS".
    Modified implementation of Sql\Select and oracle specific
    SelectDecorator to reflect the correct behavior
  2. @tux-rampage

    [~TASK] Corrected @covers annotation in unit test

    tux-rampage authored
    Corrected incorrect @covers annotation in oracle specific
    SelectDecoratorTest
This page is out of date. Refresh to see the latest.
View
9 library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php
@@ -35,6 +35,15 @@ public function setSubject($select)
}
/**
+ * (non-PHPdoc)
+ * @see \Zend\Db\Sql\Select::renderTableAsAlias()
+ */
+ protected function renderTableAsAlias($table, $alias)
+ {
+ return $table . ' ' . $alias;
+ }
+
+ /**
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
*/
View
21 library/Zend/Db/Sql/Select.php
@@ -552,6 +552,25 @@ public function isTableReadOnly()
return $this->tableReadOnly;
}
+ /**
+ * Render table with alias in from/join parts
+ *
+ * @param string $table
+ * @param string $alias
+ */
+ protected function renderTableAsAlias($table, $alias)
+ {
+ return $table . ' AS ' . $alias;
+ }
+
+ /**
+ * Process the select part
+ *
+ * @param PlatformInterface $platform
+ * @param DriverInterface $driver
+ * @param ParameterContainer $parameterContainer
+ * @return null|array
+ */
protected function processSelect(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
{
$expr = 1;
@@ -585,7 +604,7 @@ protected function processSelect(PlatformInterface $platform, DriverInterface $d
if ($alias) {
$fromTable = $platform->quoteIdentifier($alias);
- $table .= ' AS ' . $fromTable;
+ $table = $this->renderTableAsAlias($table, $fromTable);
} else {
$fromTable = $table;
}
View
52 tests/ZendTest/Db/Sql/Platform/Oracle/SelectDecoratorTest.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Db
+ */
+
+namespace ZendTest\Db\Sql\Platform\Oracle;
+
+use Zend\Db\Sql\Platform\Oracle\SelectDecorator;
+use Zend\Db\Sql\Select;
+use Zend\Db\Adapter\ParameterContainer;
+use Zend\Db\Adapter\Platform\Oracle as OraclePlatform;
+
+class SelectDecoratorTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @testdox integration test: Testing SelectDecorator will use Select an internal state to prepare a proper from alias sql statement
+ * @covers Zend\Db\Sql\Platform\Oracle\SelectDecorator::getSqlString
+ * @dataProvider dataProvider
+ */
+ public function testGetSqlString(Select $select, $expectedSql)
+ {
+ $parameterContainer = new ParameterContainer;
+ $statement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface');
+ $statement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($parameterContainer));
+
+ $selectDecorator = new SelectDecorator;
+ $selectDecorator->setSubject($select);
+ $this->assertEquals($expectedSql, $selectDecorator->getSqlString(new OraclePlatform));
+ }
+
+ /**
+ * Data provider for testGetSqlString
+ *
+ * @return array
+ */
+ public function dataProvider()
+ {
+ $select0 = new Select;
+ $select0->from(array('x' => 'foo'));
+ $expectedSql0 = 'SELECT "x".* FROM "foo" "x"';
+
+ return array(
+ array($select0, $expectedSql0),
+ );
+ }
+
+}
Something went wrong with that request. Please try again.