Unverified Commit 0a34a67c authored by belgattitude's avatar belgattitude Committed by Luís Cobucci

More tests for escaping

parent d2ddd2f0
...@@ -390,22 +390,28 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -390,22 +390,28 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
} }
/** /**
* Test that default value escaping does not trigger a schema change
* using different escaping options.
* @link https://mariadb.com/kb/en/library/string-literals * @link https://mariadb.com/kb/en/library/string-literals
* @link https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
*/ */
public function testColumnDefaultValuesEscaping(): void public function testColumnDefaultValuesEscaping(): void
{ {
$table = new Table("test_column_default_values_escaping"); $table = new Table("test_column_default_values_escaping");
$table->addColumn('no_quotes', 'string', ['notnull' => false, 'default' => 'az']); $table->addColumn('double_backslash', 'string', ['default' => 'F\\Q\\D\\N']);
$table->addColumn('triple_backslash', 'string', ['default' => 'a\\\z']);
$table->addColumn('backslash', 'string', ['notnull' => false, 'default' => 'a\\\z']); $table->addColumn('repeated_single_quotes', 'string', ['default' => "a''z"]);
$table->addColumn('repeated_single_quotes', 'string', ['notnull' => false, 'default' => "a''z"]); $table->addColumn('backslash_double_quote', 'string', ['default' => 'a\"z']);
$table->addColumn('backslash_newline', 'string', ['default' => 'a\nz']);
$this->_sm->dropAndCreateTable($table); $this->_sm->dropAndCreateTable($table);
$onlineTable = $this->_sm->listTableDetails("test_column_default_values_escaping"); $onlineTable = $this->_sm->listTableDetails("test_column_default_values_escaping");
self::assertSame("az", $onlineTable->getColumn('no_quotes')->getDefault()); self::assertSame('F\\Q\\D\\N', $onlineTable->getColumn('double_backslash')->getDefault());
self::assertSame('a\\\z', $onlineTable->getColumn('backslash')->getDefault()); self::assertSame('a\\\z', $onlineTable->getColumn('triple_backslash')->getDefault());
self::assertSame("a''z", $onlineTable->getColumn('repeated_single_quotes')->getDefault()); self::assertSame("a''z", $onlineTable->getColumn('repeated_single_quotes')->getDefault());
self::assertSame('a\"z', $onlineTable->getColumn('backslash_double_quote')->getDefault());
self::assertSame('a\nz', $onlineTable->getColumn('backslash_newline')->getDefault());
$comparator = new Comparator(); $comparator = new Comparator();
......
...@@ -917,7 +917,7 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase ...@@ -917,7 +917,7 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
]; ];
self::assertSame(sprintf( self::assertSame(sprintf(
" DEFAULT %s", ' DEFAULT %s',
$this->_platform->quoteStringLiteral("'O'Connor said: \"Hello\" \ \r'") $this->_platform->quoteStringLiteral("'O'Connor said: \"Hello\" \ \r'")
), ),
$this->_platform->getDefaultValueDeclarationSQL($field) $this->_platform->getDefaultValueDeclarationSQL($field)
......
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