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

SQL::Translator::Parser::MySQL doesn't accept 'character set' after 'create database' #101

Open
borisdaeppen opened this issue Mar 5, 2018 · 1 comment

Comments

@borisdaeppen
Copy link

This statement:

sqlt-graph -f MySQL -o fail.png -t png fail.sql

produces the following error:

       ERROR (line 3): Invalid statement: Was expecting comment, or use, or
                       set, or drop, or create, or alter, or insert, or
                       delimiter, or empty statement
Error: translate: Error with parser 'SQL::Translator::Parser::MySQL':  no results at ~/perl5/perlbrew/perls/perl-5.22.4/bin/sqlt-graph line 195.

The following SQL was used to produce the error:

SET NAMES 'utf8';
CREATE DATABASE example CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE example;

CREATE TABLE articel (
    id INTEGER NOT NULL AUTO_INCREMENT,
    name VARCHAR(255) NOT NULL
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

When I remove CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci from the create statement, it parses just fine.

Note: The character set for the table does not produce an error.

According to https://dev.mysql.com/doc/refman/5.7/en/charset-database.html the used syntax for a character set in create should be valid.

@borisdaeppen borisdaeppen changed the title SQL::Translator::Parser::MySQL doesn't accept character set in create SQL::Translator::Parser::MySQL doesn't accept 'character set' in 'create' Mar 5, 2018
@borisdaeppen borisdaeppen changed the title SQL::Translator::Parser::MySQL doesn't accept 'character set' in 'create' SQL::Translator::Parser::MySQL doesn't accept 'character set' in 'create database' Mar 5, 2018
@borisdaeppen borisdaeppen changed the title SQL::Translator::Parser::MySQL doesn't accept 'character set' in 'create database' SQL::Translator::Parser::MySQL doesn't accept 'character set' after 'create database' Mar 5, 2018
@borisdaeppen
Copy link
Author

I'll might give it a try and create a patch, if someone with a good amount of background knowledge on MySQL (or somebody from the devs of sqlfairy) can confirm that this is a valid issue.

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