Skip to content

Commit

Permalink
Remove parameter $withColumn from `QuoterInterface::getTableNamePar…
Browse files Browse the repository at this point in the history
…ts()`, Remove `Quoter::unquoteParts()` (#840)
  • Loading branch information
Tigrov authored May 9, 2024
1 parent b4254af commit 68823a6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
of `AbstractDMLQueryBuilder` class (@Tigrov)
- Chg #838: Remove `SchemaInterface::TYPE_JSONB` constant (@Tigrov)
- Chg #839: Remove `TableSchemaInterface::compositeForeignKey()` method (@Tigrov)
- Chg #840: Remove parameter `$withColumn` from `QuoterInterface::getTableNameParts()` method (@Tigrov)
- Chg #840: Remove `Quoter::unquoteParts()` method (@Tigrov)

## 1.3.0 March 21, 2024

Expand Down
8 changes: 5 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ $db->createCommand()->insertBatch('user', $values)->execute();

- `QuoterInterface::getRawTableName()` - returns the raw table name without quotes.

### Remove deprecated methods
### Remove methods

- `AbstractDMLQueryBuilder::getTypecastValue()`
- `TableSchemaInterface::compositeForeignKey()`
- `Quoter::unquoteParts()`

### Remove deprecated parameters

- `$table` parameter from `AbstractDMLQueryBuilder::normalizeColumnNames()` method
- `$table` parameter from `AbstractDMLQueryBuilder::getNormalizeColumnNames()` method
- `$table` from `AbstractDMLQueryBuilder::normalizeColumnNames()` method
- `$table` from `AbstractDMLQueryBuilder::getNormalizeColumnNames()` method
- `$withColumn` from `QuoterInterface::getTableNameParts()` method

### Remove deprecated constants

Expand Down
23 changes: 3 additions & 20 deletions src/Schema/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Yiisoft\Db\Expression\ExpressionInterface;

use function addcslashes;
use function array_map;
use function array_slice;
use function count;
use function explode;
Expand Down Expand Up @@ -94,11 +95,11 @@ public function getRawTableName(string $name): string
return $name;
}

public function getTableNameParts(string $name, bool $withColumn = false): array
public function getTableNameParts(string $name): array
{
$parts = array_slice(explode('.', $name), -2, 2);

return $this->unquoteParts($parts, $withColumn);
return array_map([$this, 'unquoteSimpleTableName'], $parts);
}

public function ensureNameQuoted(string $name): string
Expand Down Expand Up @@ -245,22 +246,4 @@ public function unquoteSimpleTableName(string $name): string
? $name
: substr($name, 1, -1);
}

/**
* @psalm-param string[] $parts Parts of table name
*
* @psalm-return string[]
*/
protected function unquoteParts(array $parts, bool $withColumn): array
{
$lastKey = count($parts) - 1;

foreach ($parts as $k => &$part) {
$part = ($withColumn && $lastKey === $k) ?
$this->unquoteSimpleColumnName($part) :
$this->unquoteSimpleTableName($part);
}

return $parts;
}
}
3 changes: 1 addition & 2 deletions src/Schema/QuoterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ public function getRawTableName(string $name): string;
* Splits full table name into parts.
*
* @param string $name The full name of the table.
* @param bool $withColumn Deprecated. Will be removed in version 2.0.0.
*
* @return string[] The table name parts.
*/
public function getTableNameParts(string $name, bool $withColumn = false): array;
public function getTableNameParts(string $name): array;

/**
* Ensures name is wrapped with `{{ and }}`.
Expand Down

0 comments on commit 68823a6

Please sign in to comment.