-
Notifications
You must be signed in to change notification settings - Fork 121
TableIdentifier schema parameter to allow arrays for use in quoteIdentifierChain to express full object path. #232
base: master
Are you sure you want to change the base?
Conversation
…wing array as parameter for $schema in TableIdentifier
src/Sql/AbstractSql.php
Outdated
@@ -3,7 +3,7 @@ | |||
* Zend Framework (http://framework.zend.com/) | |||
* | |||
* @link http://github.com/zendframework/zf2 for the canonical source repository | |||
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) | |||
* @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong license header
src/Sql/AbstractSql.php
Outdated
@@ -435,7 +435,7 @@ protected function resolveTable( | |||
} | |||
|
|||
if ($schema && $table) { | |||
$table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; | |||
$table = $platform->quoteIdentifierChain($schema).$platform->getIdentifierSeparator() . $table; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces are missing before and after the dot.
src/Sql/TableIdentifier.php
Outdated
@@ -1,9 +1,11 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong license header
src/Sql/TableIdentifier.php
Outdated
*/ | ||
public function __construct($table, $schema = null) | ||
{ | ||
if (! (is_string($table) || is_callable([$table, '__toString']))) { | ||
if (!(is_string($table) || is_callable([$table, '__toString']))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space is missing after !
.
src/Sql/TableIdentifier.php
Outdated
@@ -45,14 +47,17 @@ public function __construct($table, $schema = null) | |||
if (null === $schema) { | |||
$this->schema = null; | |||
} else { | |||
if (! (is_string($schema) || is_callable([$schema, '__toString']))) { | |||
if (!(is_string($schema) || is_array($schema) || is_callable([$schema, '__toString']))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space is missing after !.
src/Sql/TableIdentifier.php
Outdated
is_object($schema) ? get_class($schema) : gettype($schema) | ||
)); | ||
} | ||
|
||
$this->schema = (string) $schema; | ||
if (!is_array($schema)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space is missing after !.
test/Sql/TableIdentifierTest.php
Outdated
@@ -1,19 +1,23 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
test/Sql/TableIdentifierTest.php
Outdated
|
||
/** | ||
* Tests for {@see \Zend\Db\Sql\TableIdentifier} | ||
* Tests for {@see \Zend\Db\Sql\TableIdentifier}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert
test/Sql/TableIdentifierTest.php
Outdated
/** | ||
* Data provider | ||
* Data provider. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert
test/Sql/TableIdentifierTest.php
Outdated
@@ -102,7 +116,7 @@ public function invalidTableProvider() | |||
} | |||
|
|||
/** | |||
* Data provider | |||
* Data provider. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert
@alextech |
is_object($schema) ? get_class($schema) : gettype($schema) | ||
)); | ||
} | ||
|
||
$this->schema = (string) $schema; | ||
if (! is_array($schema)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably check for callable [$schema, '__toString']
only to avoid re-cast $schema that already string ?
if (is_callable([$schema, '__toString'])) {
This repository has been moved to laminas/laminas-db. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#78. |
#206 Allow expression of full path towards table by allowing array as parameter for $schema in TableIdentifier and use
quoteIdentifierChain
in Sql table resolver. Reasoning explained in the issue.While working on this noticed that
quoteIdentifierChain
tries to preform near identical operation asidentifierChain
, hence the change in theAbstractSQL
class, but in less safer way. The result is the same most of the time but it uses hardcoded strings, instead of tokens specified in the specification thatquoteIdentifier
is using, such asquoteIdentiferTo
orquoteIdentifer[0]
andgetIdentifierSeparator()
.I think this is an oversight since databases with more complex database object locator rules (PostgreSQL and SQL Server) are only now becoming more popular. Cleaning that up possibly in another PR.