Test same escaped sequences across all platforms

parent a50a029f
......@@ -483,7 +483,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
return $default;
}
$default = str_replace("\\\\", "\\", $default);
$default = str_replace("''", "'", $default);
return $default;
......
......@@ -442,30 +442,4 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$diff = $comparator->diffTable($table, $onlineTable);
self::assertFalse($diff, "Tables should be identical with column defauts time and date.");
}
/**
* Returns literals that are platform specific escaped.
*
* @see https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
*
* @return array
*/
protected function getEscapedLiterals(): array
{
return [
"\\0", // An ASCII NUL (X'00') character
"\\'", // Single quote
"''", // Single quote
'\\"', // Double quote
'""', // Double quote
'\\b', // A backspace character
'\\n', // A new-line character
'\\r', // A carriage return character
'\\t', // A tab character
'\\Z', // ASCII 26 (Control+Z)
'\\\\', // A backslash (\) character
'\\%', // A percent (%) character
'\\_', // An underscore (_) character
];
}
}
......@@ -1399,24 +1399,41 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
}
/**
* Returns literals that are platform specific escaped.
* Returns potential escaped literals from all platforms combined.
*
* @see https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
* @see http://www.sqlite.org/lang_expr.html
* @see https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE
*
* @return array
*/
protected function getEscapedLiterals() : array
public function getEscapedLiterals(): array
{
return [
"\\'", // A single quote
'\\"', // A double quote
'\\n', // A new-line character
'\\r', // A carriage return character
'An ASCII NUL (X\'00\')' => ["\\0"],
'Single quote, C-style' => ["\\'"],
'Single quote, doubled-style' => ["''"],
'Double quote, C-style' => ['\\"'],
'Double quote, double-style' => ['""'],
'Backspace' => ['\\b'],
'New-line' => ['\\n'],
'Carriage return' => ['\\r'],
'Tab' => ['\\t'],
'ASCII 26 (Control+Z)' => ['\\Z'],
'Backslash (\)' => ['\\\\'],
'Percent (%)' => ['\\%'],
'Underscore (_)' => ['\\_'],
];
}
public function testEscapedDefaultValueMustBePreserved() : void
/**
* @dataProvider getEscapedLiterals
*
* @param string $value
*/
public function testEscapedDefaultValueMustBePreserved(string $value) : void
{
$value = implode('+', $this->getEscapedLiterals());
$value = 'foo' . $value . 'bar';
$table = new Table('string_escaped_default_value');
$table->addColumn('def_string', 'string', array('default' => $value));
$table->addColumn('def_foo', 'string');
......
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