Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different between MySQL and mariadb problem #30

Open
applibs opened this issue Jun 16, 2018 · 2 comments
Open

different between MySQL and mariadb problem #30

applibs opened this issue Jun 16, 2018 · 2 comments

Comments

@applibs
Copy link

applibs commented Jun 16, 2018

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'.

@applibs
Copy link
Author

applibs commented Jun 16, 2018

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...

@applibs
Copy link
Author

applibs commented Aug 15, 2018

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);
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant