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

Unicode special characters causing 'Incorrect String value' errors (MySQL) #27

Closed
Nick-Lucas opened this issue Jul 12, 2016 · 2 comments
Labels

Comments

@Nick-Lucas
Copy link
Owner

Nick-Lucas commented Jul 12, 2016

The following string threw on .Store()
image

image

Data came from a table in utf8 and was being stored to a table of utf8mb4

@Nick-Lucas Nick-Lucas changed the title FluidMode cannot recover from special characters by expanding the CharSet FluidMode cannot recover from special characters causing 'Incorrect String value' errors Jul 12, 2016
@Nick-Lucas Nick-Lucas changed the title FluidMode cannot recover from special characters causing 'Incorrect String value' errors Unicode special characters causing 'Incorrect String value' errors Jul 13, 2016
@Nick-Lucas
Copy link
Owner Author

Nick-Lucas commented Jul 13, 2016

Running the following will reliably reproduce this crash

        static void DB(MySqlConnection c) {
            string s = "INSERT INTO " + tbl + " SET title = @title, result_data = @data, run_on = @when";

            // Adding or removing this block will reproduce the error
            var set = c.CreateCommand();
            set.CommandText = "set names utf8mb4"; // or simply utf8
            set.ExecuteNonQuery();

            var cmd = c.CreateCommand();
            cmd.CommandText = s;
            cmd.Parameters.AddWithValue("title", title);
            cmd.Parameters.AddWithValue("data", data); // contains 'Ç'
            cmd.Parameters.AddWithValue("when", run_on);
            cmd.ExecuteNonQuery();

            Console.WriteLine("DB DONE");
            Console.Read();
        }

Need to investigate why set names is required in Limebean as so far it's causing 1 issue and no solutions compared my usage of ADO in the past

@Nick-Lucas
Copy link
Owner Author

Nick-Lucas commented Jul 14, 2016

This is due to the MariaDbDetails.cs class in Limebean running set names utf8mb4 as recommended here: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html

It seems not to set everything correctly, whereas adding: characterset=utf8mb4 to the connection string causes this to work. This implied some variable is set by the connection string which is not set by set names in MySQL.

Workaround is to include the charset in the connection string

@Nick-Lucas Nick-Lucas changed the title Unicode special characters causing 'Incorrect String value' errors Unicode special characters causing 'Incorrect String value' errors (MySQL) Jul 14, 2016
@Nick-Lucas Nick-Lucas added the bug label Jul 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant