Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'hotfix/db-select-joins-reset-names' of git://github.com…

…/ralphschindler/zf2 into hotfix/3641
  • Loading branch information...
commit ec3caffbb7c8f521638b942dfe4c685a79e3367b 2 parents 585a1eb + 023fccc
@weierophinney weierophinney authored
View
9 library/Zend/Db/Sql/Select.php
@@ -607,7 +607,12 @@ protected function processSelect(PlatformInterface $platform, DriverInterface $d
$jColumns[] = $jColumnParts->getSql();
} else {
$name = (is_array($join['name'])) ? key($join['name']) : $name = $join['name'];
- $jColumns[] = $platform->quoteIdentifier($name) . $separator . $platform->quoteIdentifierInFragment($jColumn);
+ if ($name instanceof TableIdentifier) {
+ $name = $platform->quoteIdentifier($name->getSchema()) . $separator . $platform->quoteIdentifier($name->getTable());
+ } else {
+ $name = $platform->quoteIdentifier($name);
+ }
+ $jColumns[] = $name . $separator . $platform->quoteIdentifierInFragment($jColumn);
}
if (is_string($jKey)) {
$jColumns[] = $platform->quoteIdentifier($jKey);
@@ -631,6 +636,8 @@ protected function processJoins(PlatformInterface $platform, DriverInterface $dr
$joinSpecArgArray = array();
foreach ($this->joins as $j => $join) {
$joinSpecArgArray[$j] = array();
+ $joinName = null;
+ $joinAs = null;
// type
$joinSpecArgArray[$j][] = strtoupper($join['type']);
View
19 tests/ZendTest/Db/Sql/SelectTest.php
@@ -961,6 +961,24 @@ public function providerData()
'processJoins' => array(array(array('INNER', '(SELECT "bar".* FROM "bar" WHERE "y" LIKE ?) AS "z"', '"z"."foo" = "bar"."id"')))
);
+ // @link https://github.com/zendframework/zf2/issues/3294
+ // Test TableIdentifier In Joins, with multiple joins
+ $select40 = new Select;
+ $select40->from('foo')
+ ->join(array('a' => new TableIdentifier('another_foo', 'another_schema')), 'a.x = foo.foo_column')
+ ->join('bar', 'foo.colx = bar.colx');
+ $sqlPrep40 = // same
+ $sqlStr40 = 'SELECT "foo".*, "a".*, "bar".* FROM "foo"'
+ . ' INNER JOIN "another_schema"."another_foo" AS "a" ON "a"."x" = "foo"."foo_column"'
+ . ' INNER JOIN "bar" ON "foo"."colx" = "bar"."colx"';
+ $internalTests40 = array(
+ 'processSelect' => array(array(array('"foo".*'), array('"a".*'), array('"bar".*')), '"foo"'),
+ 'processJoins' => array(array(
+ array('INNER', '"another_schema"."another_foo" AS "a"', '"a"."x" = "foo"."foo_column"'),
+ array('INNER', '"bar"', '"foo"."colx" = "bar"."colx"')
+ ))
+ );
+
/**
* $select = the select object
* $sqlPrep = the sql as a result of preparation
@@ -1011,6 +1029,7 @@ public function providerData()
array($select37, $sqlPrep37, array(), $sqlStr37, $internalTests37),
array($select38, $sqlPrep38, array(), $sqlStr38, $internalTests38),
array($select39, $sqlPrep39, array(), $sqlStr39, $internalTests39),
+ array($select40, $sqlPrep40, array(), $sqlStr40, $internalTests40),
);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.