node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

JSON incompatibility with node-mysql

Open PRR24 opened this issue 2 years ago • 3 comments

node-mysql2 returns deserialized value of MySQL JSON column while node-mysql returns string. For updating/inserting, both require serialized string. I think it is worth adding to "Known incompatibilities with node-mysql" section of the documentation.

PRR24 avatar Aug 19 '23 11:08 PRR24

I think it is worth adding to "Known incompatibilities with node-mysql" section of the documentation.

Yes, agree. There was also some discussion to allow to change this behaviour via some config flag

sidorares avatar Aug 19 '23 15:08 sidorares

Met the problem with TypeORM.😆

fenying avatar Sep 09 '23 06:09 fenying

I also encountered this problem while attempting to switch our library from mysql to mysql2. A configuration flag would make it possible to switch gradually (ie. change the library and then afterwards change logic to handle deserialized objects)

sga-solita avatar Feb 06 '24 08:02 sga-solita

Closing due to #2642.

It's now possible to use this option at the connection level:

{
  jsonStrings: true,
}

Also, the known incompatibilities section has been updated by @rubenmorim:

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

wellwelwel avatar May 30 '24 19:05 wellwelwel