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

Incorrect charset collate ordering #40

Open
confuser opened this issue Jul 23, 2022 · 1 comment
Open

Incorrect charset collate ordering #40

confuser opened this issue Jul 23, 2022 · 1 comment

Comments

@confuser
Copy link
Contributor

confuser commented Jul 23, 2022

According to MySQL documentation, COLLATE must appear after CHARACTER SET https://dev.mysql.com/doc/refman/8.0/en/charset-table.html

Currently this module has it the other way around. This means when attempting to specify a collation and character set like so:

await db.createTable('test_table', {
    columns: {
      id: { type: 'int', notNull: true, primaryKey: true, autoIncrement: true },
    },
    charset: 'utf8mb4',
    collate: 'utf8mb4_unicode_ci'
  })

The following SQL is generated:

CREATE TABLE  `test_table` (`id` INTEGER  PRIMARY KEY AUTO_INCREMENT NOT NULL) COLLATE 'utf8mb4_unicode_ci' CHARACTER SET utf8mb4

This results in the correct utf8mb4 character set, but with a collation set to the default schema utf8mb4_general_ci not utf8mb4_unicode_ci

Correct SQL generated:

CREATE TABLE  `test_table` (`id` INTEGER  PRIMARY KEY AUTO_INCREMENT NOT NULL) CHARACTER SET utf8mb4 COLLATE 'utf8mb4_unicode_ci'

@wzrdtales would you be open to a PR to resolve this? Looks like spec.collate and spec.charset need swapping in _applyTableOptions

@wzrdtales
Copy link
Member

always, as you noted, things go under the radar (need some different mail setup for github i think). We also would welcome new additional maintainers to this module (just mentioning if you might be interested to help).

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

2 participants