Loading core/modules/pgsql/src/Driver/Database/pgsql/Schema.php +1 −1 Original line number Diff line number Diff line Loading @@ -575,7 +575,7 @@ public function renameTable($table, $new_name) { // exceed the 63 chars limit of PostgreSQL, we need to take care of that. // cSpell:disable-next-line // Example (drupal_Gk7Su_T1jcBHVuvSPeP22_I3Ni4GrVEgTYlIYnBJkro_idx). if (str_contains($index->indexname, 'drupal_')) { if (str_starts_with($index->indexname, 'drupal_')) { preg_match('/^drupal_(.*)_' . preg_quote($index_type, NULL) . '/', $index->indexname, $matches); $index_name = $matches[1]; } Loading core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php +29 −0 Original line number Diff line number Diff line Loading @@ -365,6 +365,35 @@ public function testRenameTableWithNewIndexNameEqualsTableName(): void { $this->assertTrue($this->schema->tableExists($table_name_new)); } /** * Tests renaming a table which name contains drupal_ with multiple indexes. */ public function testRenameTableWithNameContainingDrupalUnderscoreAndMultipleIndexes(): void { $table_name_old = 'field_drupal_foo'; $table_name_new = 'field_drupal_bar'; $table_specification = [ 'fields' => [ 'one' => [ 'type' => 'int', 'default' => NULL, ], 'two' => [ 'type' => 'int', 'default' => NULL, ], ], 'indexes' => [ 'one' => ['one'], 'two' => ['two'], ], ]; $this->schema->createTable($table_name_old, $table_specification); $this->schema->renameTable($table_name_old, $table_name_new); $this->assertTrue($this->schema->tableExists($table_name_new)); } /** * Tests column name escaping in field constraints. */ Loading Loading
core/modules/pgsql/src/Driver/Database/pgsql/Schema.php +1 −1 Original line number Diff line number Diff line Loading @@ -575,7 +575,7 @@ public function renameTable($table, $new_name) { // exceed the 63 chars limit of PostgreSQL, we need to take care of that. // cSpell:disable-next-line // Example (drupal_Gk7Su_T1jcBHVuvSPeP22_I3Ni4GrVEgTYlIYnBJkro_idx). if (str_contains($index->indexname, 'drupal_')) { if (str_starts_with($index->indexname, 'drupal_')) { preg_match('/^drupal_(.*)_' . preg_quote($index_type, NULL) . '/', $index->indexname, $matches); $index_name = $matches[1]; } Loading
core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php +29 −0 Original line number Diff line number Diff line Loading @@ -365,6 +365,35 @@ public function testRenameTableWithNewIndexNameEqualsTableName(): void { $this->assertTrue($this->schema->tableExists($table_name_new)); } /** * Tests renaming a table which name contains drupal_ with multiple indexes. */ public function testRenameTableWithNameContainingDrupalUnderscoreAndMultipleIndexes(): void { $table_name_old = 'field_drupal_foo'; $table_name_new = 'field_drupal_bar'; $table_specification = [ 'fields' => [ 'one' => [ 'type' => 'int', 'default' => NULL, ], 'two' => [ 'type' => 'int', 'default' => NULL, ], ], 'indexes' => [ 'one' => ['one'], 'two' => ['two'], ], ]; $this->schema->createTable($table_name_old, $table_specification); $this->schema->renameTable($table_name_old, $table_name_new); $this->assertTrue($this->schema->tableExists($table_name_new)); } /** * Tests column name escaping in field constraints. */ Loading