Unverified Commit 6b9ead7f authored by belgattitude's avatar belgattitude Committed by Luís Cobucci

Review from @morozov about nulls

parent 4ddc496d
......@@ -220,9 +220,15 @@ class MySqlSchemaManager extends AbstractSchemaManager
* - CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE are stored in information_schema
* as current_timestamp(), currdate(), currtime()
* - Literal escaping is normalized in information schema (store "''" instead of "\'")
* - Note: columnDefault should only be null when column is not_nullable otherwise
* a string 'NULL' should be given. Unfortunately, it's not 100% correct in case of
* upgrade from previous versions: see https://jira.mariadb.org/browse/MDEV-14053.
* Otherwise we could simplify the condition === 'NULL' || === null by adding the parameter
* is_nullable.
*
* @link https://mariadb.com/kb/en/library/information-schema-columns-table/
* @link https://jira.mariadb.org/browse/MDEV-13132
* @link https://jira.mariadb.org/browse/MDEV-14053
*
* @param null|string $columnDefault default value as stored in information_schema for MariaDB >= 10.2.7
*/
......
......@@ -423,18 +423,18 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$sql = "
CREATE TABLE test_column_defaults_with_create (
col1 VARCHAR(255) NULL DEFAULT 'O''Connor\'\"',
col2 VARCHAR(255) NULL DEFAULT '''A'''
col2 VARCHAR(255) NOT NULL DEFAULT 'O''Connor\'\"'
);
";
$this->_conn->query($sql);
$onlineTable = $this->_sm->listTableDetails("test_column_defaults_with_create");
self::assertSame("O'Connor'\"", $onlineTable->getColumn('col1')->getDefault());
self::assertSame("'A'", $onlineTable->getColumn('col2')->getDefault());
self::assertSame("O'Connor'\"", $onlineTable->getColumn('col2')->getDefault());
$table = new Table("test_column_defaults_no_diff");
$table->addColumn('col1', 'string', ['notnull' => false, 'default' => "O'Connor'\""]);
$table->addColumn('col2', 'string', ['notnull' => false, 'default' => "'A'"]);
$table->addColumn('col2', 'string', ['notnull' => true, 'default' => "O'Connor'\""]);
$comparator = new Comparator();
$diff = $comparator->diffTable($table, $onlineTable);
......
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