Sqlx: Support JSON for Postgres

Created on 28 Dec 2019  路  5Comments  路  Source: launchbadge/sqlx

Support taking and returning serde_json::Value (maybe others as well?) in queries.

I think this would be a Postgres-only feature, right?

postgres enhancement

Most helpful comment

JSON for Postgres is in master. Thanks @oeb25! I'll spin out another issue for MySQL.

All 5 comments

Postgres has first class JSON support, but technically you can store JSON in text blobs in mysql as well - Indeed we actually do exactly that at my work.

We could serialize JSON to text for MySQL but the query!() macro couldn't possibly know to read out a varchar field as JSON.

We could make it work with query_as!() but it'd be difficult to discover serendipitously; we'd need an example showing it.

I'm not an expert in MySQL, but why this isn't suiting? https://dev.mysql.com/doc/refman/8.0/en/json.html

It depends on the MySQL version. We're still using 5.6. because of some other tooling requirements, so it's not available there. If you're on a new enough version then that would make it a lot easier though :)

JSON for Postgres is in master. Thanks @oeb25! I'll spin out another issue for MySQL.

Was this page helpful?
0 / 5 - 0 ratings