different between MySQL and mariadb problem
applibs opened this issue · comments
I found that using SHOW CREATE TABLE 'xxx' is different result.
I have mariadb on development and mysql on production. Problem is for example DEFAULT, one is DEFAULT 0 and second db is DEFAULT '0'.
I found some info:
https://mariadb.com/kb/en/library/server-system-variables/#sql_quote_show_create
but not works well. This is another info about this:
https://jira.mariadb.org/browse/MDEV-15377
https://jira.mariadb.org/browse/MDEV-13244
I see that this library accept only DEFAULT values in quotes. It ignore "DEFAULT 0" for example.
Your code is:
if (!empty($defaultValue))
but when $defaultValue is "0" it doesnot work. Same for "0.00" etc...
this is my fix at Column class:
if (!is_null($this->defaultValue) && $this->nullable === false) {
if($this->defaultValue === "''" || $this->defaultValue === 'CURRENT_TIMESTAMP') {
$columnOptions[] = sprintf('DEFAULT %s', $this->defaultValue);
}
else {
$columnOptions[] = sprintf("DEFAULT '%s'", $this->defaultValue);
}
}
and at Parser class and function parseColumns:
if($defaultValue !== '' && $defaultValue !== "''") {
$defaultValue = trim($defaultValue,"'");
}
if (!is_null($defaultValue) && $defaultValue !== '') {
$column->setDefaultValue($defaultValue);
}