From 583d56a66e31ffa8af4c423ca29a005ea7884e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 17 Jul 2022 16:48:45 +0200 Subject: [PATCH] Allow to backport #4804 --- src/Platforms/SqlitePlatform.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php index 6d5adda49c8..9ab23d50b00 100644 --- a/src/Platforms/SqlitePlatform.php +++ b/src/Platforms/SqlitePlatform.php @@ -328,6 +328,17 @@ protected function _getCommonIntegerTypeDeclarationSQL(array $column) return ! empty($column['unsigned']) ? ' UNSIGNED' : ''; } + /** + * To backport https://github.com/doctrine/dbal/pull/4804 override + * this method to return unchanged $tableName. + * + * Removed in DBAL v4.0. + */ + protected function emulateSchemaInTableName(string $tableName): string + { + return str_replace('.', '__', $tableName); + } + /** * {@inheritDoc} */ @@ -335,7 +346,7 @@ public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) { return parent::getForeignKeyDeclarationSQL(new ForeignKeyConstraint( $foreignKey->getQuotedLocalColumns($this), - str_replace('.', '__', $foreignKey->getQuotedForeignTableName($this)), + $this->emulateSchemaInTableName($foreignKey->getQuotedForeignTableName($this)), $foreignKey->getQuotedForeignColumns($this), $foreignKey->getName(), $foreignKey->getOptions() @@ -347,7 +358,7 @@ public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) */ protected function _getCreateTableSQL($name, array $columns, array $options = []) { - $name = str_replace('.', '__', $name); + $name = $this->emulateSchemaInTableName($name); $queryFields = $this->getColumnDeclarationListSQL($columns); if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) { @@ -461,7 +472,7 @@ public function getClobTypeDeclarationSQL(array $column) */ public function getListTableConstraintsSQL($table) { - $table = str_replace('.', '__', $table); + $table = $this->emulateSchemaInTableName($table); return sprintf( "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = %s AND sql NOT NULL ORDER BY name", @@ -474,7 +485,7 @@ public function getListTableConstraintsSQL($table) */ public function getListTableColumnsSQL($table, $database = null) { - $table = str_replace('.', '__', $table); + $table = $this->emulateSchemaInTableName($table); return sprintf('PRAGMA table_info(%s)', $this->quoteStringLiteral($table)); } @@ -484,7 +495,7 @@ public function getListTableColumnsSQL($table, $database = null) */ public function getListTableIndexesSQL($table, $database = null) { - $table = str_replace('.', '__', $table); + $table = $this->emulateSchemaInTableName($table); return sprintf('PRAGMA index_list(%s)', $this->quoteStringLiteral($table)); } @@ -586,7 +597,7 @@ public function getName() public function getTruncateTableSQL($tableName, $cascade = false) { $tableIdentifier = new Identifier($tableName); - $tableName = str_replace('.', '__', $tableIdentifier->getQuotedName($this)); + $tableName = $this->emulateSchemaInTableName($tableIdentifier->getQuotedName($this)); return 'DELETE FROM ' . $tableName; } @@ -792,7 +803,7 @@ public function getBlobTypeDeclarationSQL(array $column) */ public function getTemporaryTableName($tableName) { - $tableName = str_replace('.', '__', $tableName); + $tableName = $this->emulateSchemaInTableName($tableName); return $tableName; } @@ -881,7 +892,7 @@ public function getCreateTableSQL(Table $table, $createFlags = null) */ public function getListTableForeignKeysSQL($table, $database = null) { - $table = str_replace('.', '__', $table); + $table = $this->emulateSchemaInTableName($table); return sprintf('PRAGMA foreign_key_list(%s)', $this->quoteStringLiteral($table)); }