Skip to content

Use mysql2 lib to be able to use MySQL 8#20

Open
atog wants to merge 2 commits into
sailshq:masterfrom
atog:master
Open

Use mysql2 lib to be able to use MySQL 8#20
atog wants to merge 2 commits into
sailshq:masterfrom
atog:master

Conversation

@atog

@atog atog commented Sep 28, 2023

Copy link
Copy Markdown

No description provided.

@fengzai6

fengzai6 commented Sep 2, 2024

Copy link
Copy Markdown

I need it too

@fengzai6

Copy link
Copy Markdown

sometime use find function will throw error:AdapterError: Unexpected error from database adapter: "[object Object]" is not valid JSON

@Harm-Nullix

Copy link
Copy Markdown

Why is this not merged by 2024?
https://endoflife.date/mysql

@Harm-Nullix

Harm-Nullix commented Oct 21, 2024

Copy link
Copy Markdown

@mikermcneil ,
@eashaw , any light on this?

@MarijnMensinga

MarijnMensinga commented Oct 22, 2024

Copy link
Copy Markdown

@fengzai6 and @Harm-Nullix I found the issue. If a model property has type json and the database fieldType is also json mysql2 returns the data as parsed (json) object instead of the json string. Therefore a small change is needed in sails-mysql as well. Since this ticket/library seems dormant I've created a fork with the fixed in it. If you want you could add
"sails-mysql": "https://gitlab.com/newtee-public/balderdashy-sails-mysql.git" to your package.json and you'll be able to use mysql 8 with your sails backend. It also packs the fixed dependency from this PR: https://gitlab.com/newtee-public/sailshq-machinepack-mysql2

@fengzai6

Copy link
Copy Markdown

@fengzai6 and @Harm-Nullix I found the issue. If a model property has type json and the database fieldType is also json mysql2 returns the data as parsed (json) object instead of the json string. Therefore a small change is needed in sails-mysql as well. Since this ticket/library seems dormant I've created a fork with the fixed in it. If you want you could add "sails-mysql": "https://gitlab.com/newtee-public/balderdashy-sails-mysql.git" to your package.json and you'll be able to use mysql 8 with your sails backend. It also packs the fixed dependency from this PR: https://gitlab.com/newtee-public/sailshq-machinepack-mysql2

OK,I will try it, thx!

@maheshwarishivam

Copy link
Copy Markdown

@eashaw Any update on this. When can we have MySQL 8 compatibility?

@kei-katahira

kei-katahira commented Mar 24, 2025

Copy link
Copy Markdown

You might consider setting the jsonStrings option in MySQL2 to true.
This will ensure that JSON data retrieved from MySQL is consistently returned as strings and avoid parsing problems.

https://sidorares.github.io/node-mysql2/docs/documentation#known-incompatibilities-with-node-mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants