diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 9259c6729b..ba7b3fc65f 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -460,7 +460,7 @@ public function getFullQualifiedTableName($table) { */ public function prepareQuery($query, array $options = []) { $query = $this->prefixTables($query); - if (!empty($options['real_square_brackets'])) { + if (empty($options['real_square_brackets'])) { $query = $this->quoteIdentifiers($query); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php index 47e11dadf9..080f4787b3 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php @@ -155,23 +155,4 @@ public function testMultipleStatements() { } } - /** - * Test the escapeTable(), escapeField() and escapeAlias() methods with all possible reserved words in PostgreSQL. - */ - public function testPostgresqlReservedWords() { - if (Database::getConnection()->databaseType() !== 'pgsql') { - return; - } - - $db = Database::getConnection('default', 'default'); - $stmt = $db->query("SELECT word FROM pg_get_keywords() WHERE catcode IN ('R', 'T')"); - $stmt->execute(); - foreach ($stmt->fetchAllAssoc('word') as $word => $row) { - $expected = '"' . $word . '"'; - $this->assertIdentical($db->escapeTable($word), $expected, format_string('The reserved word %word was correctly escaped when used as a table name.', ['%word' => $word])); - $this->assertIdentical($db->escapeField($word), $expected, format_string('The reserved word %word was correctly escaped when used as a column name.', ['%word' => $word])); - $this->assertIdentical($db->escapeAlias($word), $expected, format_string('The reserved word %word was correctly escaped when used as an alias.', ['%word' => $word])); - } - } - }