Skip to content

Commit 37042ac

Browse files
committed
Remove Schema\Identifier
1 parent f8f6751 commit 37042ac

31 files changed

+505
-452
lines changed

src/DriverManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* @phpstan-type OverrideParams = array{
2727
* application_name?: string,
2828
* charset?: string,
29-
* dbname?: string,
29+
* dbname?: non-empty-string,
3030
* defaultTableOptions?: array<string, mixed>,
3131
* driver?: key-of<self::DRIVER_MAP>,
3232
* driverClass?: class-string<Driver>,
@@ -39,14 +39,14 @@
3939
* port?: int,
4040
* serverVersion?: string,
4141
* sessionMode?: int,
42-
* user?: string,
42+
* user?: non-empty-string,
4343
* unix_socket?: string,
4444
* wrapperClass?: class-string<Connection>,
4545
* }
4646
* @phpstan-type Params = array{
4747
* application_name?: string,
4848
* charset?: string,
49-
* dbname?: string,
49+
* dbname?: non-empty-string,
5050
* defaultTableOptions?: array<string, mixed>,
5151
* driver?: key-of<self::DRIVER_MAP>,
5252
* driverClass?: class-string<Driver>,
@@ -62,7 +62,7 @@
6262
* replica?: array<OverrideParams>,
6363
* serverVersion?: string,
6464
* sessionMode?: int,
65-
* user?: string,
65+
* user?: non-empty-string,
6666
* wrapperClass?: class-string<Connection>,
6767
* unix_socket?: string,
6868
* }

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ protected function _getCreateTableSQL(OptionallyQualifiedName $tableName, array
243243
$sql[] = 'TEMPORARY';
244244
}
245245

246-
$sql[] = 'TABLE ' . $tableName->toSQL($this) . ' (' . implode(', ', $elements) . ')';
246+
$tableNameSQL = $tableName->toSQL($this);
247+
248+
$sql[] = sprintf('TABLE %s (%s)', $tableNameSQL, implode(', ', $elements));
247249

248250
$tableOptions = $this->buildTableOptions($parameters);
249251

@@ -259,19 +261,19 @@ protected function _getCreateTableSQL(OptionallyQualifiedName $tableName, array
259261

260262
if (isset($parameters['foreignKeys'])) {
261263
foreach ($parameters['foreignKeys'] as $definition) {
262-
$sql[] = $this->getCreateForeignKeySQL($definition, $tableName->toSQL($this));
264+
$sql[] = $this->getCreateForeignKeySQL($definition, $tableNameSQL);
263265
}
264266
}
265267

266268
return $sql;
267269
}
268270

269-
public function getCreateIndexSQL(Index $index, string $table): string
271+
public function getCreateIndexSQL(Index $index, string $tableName): string
270272
{
271273
$this->ensureIndexIsNotClustered($index);
272274
$this->ensureIndexIsNotPartial($index);
273275

274-
return parent::getCreateIndexSQL($index, $table);
276+
return parent::getCreateIndexSQL($index, $tableName);
275277
}
276278

277279
/**
@@ -557,19 +559,22 @@ protected function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreign
557559
return $query;
558560
}
559561

560-
public function getDropIndexSQL(string $name, string $table): string
562+
public function getDropIndexSQL(string $indexName, string $tableName): string
561563
{
562-
return 'DROP INDEX ' . $name . ' ON ' . $table;
564+
$parsedIndexName = $this->parseUnqualifiedName($indexName);
565+
$parsedTableName = $this->parseOptionallyQualifiedName($tableName);
566+
567+
return sprintf('DROP INDEX %s ON %s', $parsedIndexName->toSQL($this), $parsedTableName->toSQL($this));
563568
}
564569

565570
/**
566571
* The `ALTER TABLE ... DROP CONSTRAINT` syntax is only available as of MySQL 8.0.19.
567572
*
568573
* @link https://dev.mysql.com/doc/refman/8.0/en/alter-table.html
569574
*/
570-
public function getDropUniqueConstraintSQL(string $name, string $tableName): string
575+
public function getDropUniqueConstraintSQL(string $constraintName, string $tableName): string
571576
{
572-
return $this->getDropIndexSQL($name, $tableName);
577+
return $this->getDropIndexSQL($constraintName, $tableName);
573578
}
574579

575580
public function getSetTransactionIsolationSQL(TransactionIsolationLevel $level): string
@@ -621,9 +626,11 @@ protected function initializeDoctrineTypeMappings(): void
621626
* MySQL commits a transaction implicitly when DROP TABLE is executed, however not
622627
* if DROP TEMPORARY TABLE is executed.
623628
*/
624-
public function getDropTemporaryTableSQL(string $table): string
629+
public function getDropTemporaryTableSQL(string $tableName): string
625630
{
626-
return 'DROP TEMPORARY TABLE ' . $table;
631+
$parsedName = $this->parseOptionallyQualifiedName($tableName);
632+
633+
return sprintf('DROP TEMPORARY TABLE %s', $parsedName->toSQL($this));
627634
}
628635

629636
/**

0 commit comments

Comments
 (0)