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

Need a way to set typeorm connection charset #45

Open
gregwym opened this issue Oct 14, 2018 · 3 comments
Open

Need a way to set typeorm connection charset #45

gregwym opened this issue Oct 14, 2018 · 3 comments

Comments

@gregwym
Copy link

gregwym commented Oct 14, 2018

Hi Vesper team,

First of all, thanks for this great framework! It works quite well together with TypeORM.

One thing that I couldn't find a solution myself is a way to set the connection charset for MySQL. With Typeorm, I can do the following

  // read connection options from ormconfig file (or ENV variables)
  const connectionOptions = await getConnectionOptions();

  // create a connection using modified connection options
  const connection = await createConnection({
    ...connectionOptions,
    charset: 'UTF8MB4_GENERAL_CI',
  } as MysqlConnectionOptions);

It's not been loaded from option reader so this seems the only option.
I'm thinking we can either allow passing a connection to Vesper or Vesper reuse the existing default connection automatically (instead of die with AlreadyHasActiveConnectionError).

@gregwym
Copy link
Author

gregwym commented Oct 21, 2018

I have also tried query set names utf8mb4 after bootstrap. Even if SHOW VARIABLES indicates character_set_client is using utf8mb4 already, Typeorm isn't getting emojis correctly.

@gregwym
Copy link
Author

gregwym commented Oct 21, 2018

Update:
Adding useContainer(Container); before bootstrap together with set names utf8md4 seems solved it.

@gregwym gregwym closed this as completed Oct 21, 2018
@gregwym gregwym changed the title Need away to set typeorm connection charset Need a way to set typeorm connection charset Nov 5, 2018
@gregwym
Copy link
Author

gregwym commented Nov 5, 2018

Update:
SET NAMES utf8mb4 does not solve all the issues. I will dig more into the code to see if its possible to solve it on typeorm layer properly.

@gregwym gregwym reopened this Nov 5, 2018
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