Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove parameter $withColumn from Quoter::getTableNameParts() #840

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading