Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MySQL table compiler charset usage incompatible with npm mysql API #2742

@emilgoldsmith

Description

@emilgoldsmith

Sorry, ditching the template because I think I can explain it clearly enough and I'm going to submit a PR asap with a possible fix.

Basically as can be seen here https://github.com/mysqljs/mysql/blob/cf5d1e396a343ffa0fba23b3791d2dd5da20f30e/Readme.md#connection-options the documentation for the charset config option in mysql is (and has been so the last 4 years):

charset: The charset for the connection. This is called "collation" in the SQL-level of MySQL (like utf8_general_ci). If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used. (Default: 'UTF8_GENERAL_CI')

But in the Knex table compiler code there's the following https://github.com/tgriesser/knex/blob/26dfeb8805bb11b63d76065d244c78c7b380b41b/src/dialects/mysql/schema/tablecompiler.js#L34-L41

which sets what may either be a charset (that mysql finds the default collation for) or a collation as the charset. This therefore fails all my migrations when I changed to using utf8mb4_unicode_ci as my charset. Also, as far as I can see mysql has never accepted a collate option, so I'm not sure where that comes from?

I have a fix in mind and will work on it right now and submit a PR asap, I just thought it would be good form to submit an issue first, then I can also link to this for the reasoning for my PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions