From 25d1cd804bd7229e5f76e8ba4f92776bc559ffcb Mon Sep 17 00:00:00 2001 From: Tigrov Date: Thu, 9 May 2024 15:37:22 +0700 Subject: [PATCH 1/2] Remove parameter `$withColumn` from `Quoter::getTableNameParts()` method --- CHANGELOG.md | 1 + src/Quoter.php | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ffbea6b..031ba323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.0.0 under development - Enh #293: Implement `SqlParser` and `ExpressionBuilder` driver classes (@Tigrov) +- Chg #306: Remove parameter `$withColumn` from `Quoter::getTableNameParts()` method (@Tigrov) ## 1.2.0 March 21, 2024 diff --git a/src/Quoter.php b/src/Quoter.php index 5ab8d06c..7db453be 100644 --- a/src/Quoter.php +++ b/src/Quoter.php @@ -6,6 +6,8 @@ use Yiisoft\Db\Schema\Quoter as BaseQuoter; +use function array_map; +use function array_slice; use function preg_match; use function preg_match_all; @@ -23,14 +25,14 @@ public function quoteColumnName(string $name): string return parent::quoteColumnName($name); } - public function getTableNameParts(string $name, bool $withColumn = false): array + public function getTableNameParts(string $name): array { if (preg_match_all('/([^.\[\]]+)|\[([^\[\]]+)]/', $name, $matches) > 0) { $parts = array_slice($matches[0], -4, 4); - } else { - $parts = [$name]; + + return array_map([$this, 'unquoteSimpleTableName'], $parts); } - return $this->unquoteParts($parts, $withColumn); + return [$this->unquoteSimpleTableName($name)]; } } From e6ff5bae3a6b4068198ba6ba57d602c9d1701cff Mon Sep 17 00:00:00 2001 From: Tigrov Date: Thu, 9 May 2024 08:44:57 +0000 Subject: [PATCH 2/2] Apply Rector changes (CI) --- src/Quoter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Quoter.php b/src/Quoter.php index 7db453be..33d76a24 100644 --- a/src/Quoter.php +++ b/src/Quoter.php @@ -25,7 +25,7 @@ public function quoteColumnName(string $name): string return parent::quoteColumnName($name); } - public function getTableNameParts(string $name): array + public function getTableNameParts(string $name, bool $withColumn = false): array { if (preg_match_all('/([^.\[\]]+)|\[([^\[\]]+)]/', $name, $matches) > 0) { $parts = array_slice($matches[0], -4, 4);