Unverified Commit 8d2399c7 authored by Sergei Morozov's avatar Sergei Morozov

Merge branch 'bpo/2.8/#3330' into 2.8

parents c0195cde 13df030b
...@@ -36,7 +36,6 @@ use function func_num_args; ...@@ -36,7 +36,6 @@ use function func_num_args;
use function implode; use function implode;
use function preg_match; use function preg_match;
use function sprintf; use function sprintf;
use function str_replace;
use function strlen; use function strlen;
use function strpos; use function strpos;
use function strtoupper; use function strtoupper;
...@@ -1180,14 +1179,4 @@ END;'; ...@@ -1180,14 +1179,4 @@ END;';
{ {
return 'BLOB'; return 'BLOB';
} }
/**
* {@inheritdoc}
*/
public function quoteStringLiteral($str)
{
$str = str_replace('\\', '\\\\', $str); // Oracle requires backslashes to be escaped aswell.
return parent::quoteStringLiteral($str);
}
} }
...@@ -42,7 +42,6 @@ use function is_array; ...@@ -42,7 +42,6 @@ use function is_array;
use function is_bool; use function is_bool;
use function is_numeric; use function is_numeric;
use function is_string; use function is_string;
use function str_replace;
use function strpos; use function strpos;
use function strtolower; use function strtolower;
use function trim; use function trim;
...@@ -1205,16 +1204,6 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -1205,16 +1204,6 @@ class PostgreSqlPlatform extends AbstractPlatform
return 'BYTEA'; return 'BYTEA';
} }
/**
* {@inheritdoc}
*/
public function quoteStringLiteral($str)
{
$str = str_replace('\\', '\\\\', $str); // PostgreSQL requires backslashes to be escaped aswell.
return parent::quoteStringLiteral($str);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
<?php
namespace Doctrine\Tests\DBAL\Functional\Platform;
use Doctrine\Tests\DbalFunctionalTestCase;
class QuotingTest extends DbalFunctionalTestCase
{
/**
* @dataProvider stringLiteralProvider
*/
public function testQuoteStringLiteral(string $string) : void
{
$platform = $this->_conn->getDatabasePlatform();
$query = $platform->getDummySelectSQL(
$platform->quoteStringLiteral($string)
);
self::assertSame($string, $this->_conn->fetchColumn($query));
}
/**
* @return mixed[][]
*/
public static function stringLiteralProvider() : iterable
{
return [
'backslash' => ['\\'],
'single-quote' => ["'"],
];
}
}
...@@ -922,7 +922,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -922,7 +922,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/ */
public function testQuotesTableNameInListTableForeignKeysSQL() public function testQuotesTableNameInListTableForeignKeysSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -931,7 +931,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -931,7 +931,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public function testQuotesSchemaNameInListTableForeignKeysSQL() public function testQuotesSchemaNameInListTableForeignKeysSQL()
{ {
self::assertContains( self::assertContains(
"'Foo''Bar\\\\'", "'Foo''Bar\\'",
$this->_platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"), $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
'', '',
true true
...@@ -943,7 +943,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -943,7 +943,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/ */
public function testQuotesTableNameInListTableConstraintsSQL() public function testQuotesTableNameInListTableConstraintsSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -951,7 +951,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -951,7 +951,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/ */
public function testQuotesTableNameInListTableIndexesSQL() public function testQuotesTableNameInListTableIndexesSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -960,7 +960,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -960,7 +960,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public function testQuotesSchemaNameInListTableIndexesSQL() public function testQuotesSchemaNameInListTableIndexesSQL()
{ {
self::assertContains( self::assertContains(
"'Foo''Bar\\\\'", "'Foo''Bar\\'",
$this->_platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"), $this->_platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
'', '',
true true
...@@ -972,7 +972,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -972,7 +972,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/ */
public function testQuotesTableNameInListTableColumnsSQL() public function testQuotesTableNameInListTableColumnsSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -981,7 +981,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -981,7 +981,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public function testQuotesSchemaNameInListTableColumnsSQL() public function testQuotesSchemaNameInListTableColumnsSQL()
{ {
self::assertContains( self::assertContains(
"'Foo''Bar\\\\'", "'Foo''Bar\\'",
$this->_platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"), $this->_platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
'', '',
true true
...@@ -994,7 +994,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -994,7 +994,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL() public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL()
{ {
self::assertContains( self::assertContains(
"'Foo''Bar\\\\'", "'Foo''Bar\\'",
$this->_platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\"), $this->_platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\"),
'', '',
true true
......
...@@ -845,7 +845,7 @@ EOD; ...@@ -845,7 +845,7 @@ EOD;
*/ */
public function testQuotesDatabaseNameInListSequencesSQL() public function testQuotesDatabaseNameInListSequencesSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListSequencesSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListSequencesSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -853,7 +853,7 @@ EOD; ...@@ -853,7 +853,7 @@ EOD;
*/ */
public function testQuotesTableNameInListTableIndexesSQL() public function testQuotesTableNameInListTableIndexesSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -861,7 +861,7 @@ EOD; ...@@ -861,7 +861,7 @@ EOD;
*/ */
public function testQuotesTableNameInListTableForeignKeysSQL() public function testQuotesTableNameInListTableForeignKeysSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -869,7 +869,7 @@ EOD; ...@@ -869,7 +869,7 @@ EOD;
*/ */
public function testQuotesTableNameInListTableConstraintsSQL() public function testQuotesTableNameInListTableConstraintsSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -877,7 +877,7 @@ EOD; ...@@ -877,7 +877,7 @@ EOD;
*/ */
public function testQuotesTableNameInListTableColumnsSQL() public function testQuotesTableNameInListTableColumnsSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
} }
/** /**
...@@ -885,6 +885,6 @@ EOD; ...@@ -885,6 +885,6 @@ EOD;
*/ */
public function testQuotesDatabaseNameInListTableColumnsSQL() public function testQuotesDatabaseNameInListTableColumnsSQL()
{ {
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true); self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment