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

Move and deprecate Schema methods #801

Merged
merged 14 commits into from
Feb 10, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Enh #801: Deprecate `AbstractSchema::normalizeRowKeyCase()` method (@Tigrov)
- Enh #801: Deprecate `SchemaInterface::getRawTableName()` and add `QuoterInterface::getRawTableName()` method (@Tigrov)
- Enh #801: Deprecate `SchemaInterface::isReadQuery()` and add `DbStringHelper::isReadQuery()` method (@Tigrov)
- Enh #801: Remove unnecessary symbol `\\` from `rtrim()` function inside `DbStringHelper::baseName()` method (@Tigrov)
vjik marked this conversation as resolved.
Show resolved Hide resolved

## 1.2.0 November 12, 2023

Expand Down
8 changes: 5 additions & 3 deletions src/Schema/AbstractSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public function getDataType(mixed $data): int
};
}

/** @deprecated Use {@see QuoterInterface::getRawTableName()}. Will be removed in version 2.0.0. */
public function getRawTableName(string $name): string
{
if (str_contains($name, '{{')) {
Expand Down Expand Up @@ -315,6 +316,7 @@ public function getTableUniques(string $name, bool $refresh = false): array
return is_array($tableUniques) ? $tableUniques : [];
}

/** @deprecated Use {@see DbStringHelper::isReadQuery()}. Will be removed in version 2.0.0. */
public function isReadQuery(string $sql): bool
{
$pattern = '/^\s*(SELECT|SHOW|DESCRIBE)\b/i';
Expand All @@ -340,7 +342,7 @@ public function refresh(): void
*/
public function refreshTableSchema(string $name): void
{
$rawName = $this->getRawTableName($name);
$rawName = $this->db->getQuoter()->getRawTableName($name);

unset($this->tableMetadata[$rawName]);

Expand Down Expand Up @@ -470,7 +472,7 @@ protected function getSchemaMetadata(string $schema, string $type, bool $refresh
*/
protected function getTableMetadata(string $name, string $type, bool $refresh = false): mixed
{
$rawName = $this->getRawTableName($name);
$rawName = $this->db->getQuoter()->getRawTableName($name);

if (!isset($this->tableMetadata[$rawName])) {
$this->loadTableMetadataFromCache($rawName);
Expand Down Expand Up @@ -571,7 +573,7 @@ protected function resolveTableName(string $name): TableSchemaInterface
protected function setTableMetadata(string $name, string $type, mixed $data): void
{
/** @psalm-suppress MixedArrayAssignment */
$this->tableMetadata[$this->getRawTableName($name)][$type] = $data;
$this->tableMetadata[$this->db->getQuoter()->getRawTableName($name)][$type] = $data;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/SchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function getDataType(mixed $data): int;
*
* @return string The real name of the given table name.
*
* @deprecated Use {@see Quoter::getRawTableName()}. Will be removed in version 2.0.0.
* @deprecated Use {@see QuoterInterface::getRawTableName()}. Will be removed in version 2.0.0.
*/
public function getRawTableName(string $name): string;

Expand Down
Loading