Add new Postgresql.JSON.Experimental
#282
- Add JsonValue newtype wrapper to support extracting Json values from sql queries
- Added instances for SqlSelect/ToAlias*/ToMaybe
- Add new PgToJsonb typeclass to support
toJsonbfunction onValue,Entity, and tuples therof (up to 8)
Before submitting your PR, check that you've:
- [ ] Bumped the version number.
- [ ] Documented new APIs with Haddock markup.
- [ ] Added
@sincedeclarations to the Haddock. - [ ] Ran
stylish-haskelland otherwise adhered to the style guide.
After submitting your PR:
- [ ] Update the Changelog.md file with a link to your PR.
- [ ] Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts).
@parsonsmatt when you get a chance, would you mind taking a look at this. I added the typeclasses with the intention being to get as much reuse between MySQL and postgres as possible but then MySQL json support is still working it's way through the underlying libraries.
@belevy
I'm wondering if you couldn't just use the JSONB type from Database.Esqueleto.PostgreSQL.JSON? 🤔
And maybe also JSONBExpr? That way you can also use all the JSON operators while aggregating etc.
Would also provide free SqlSelect, ToMaybe, ToAlias instances, to name a few.
I still don't see why the JSONB newtype isn't used?
- Move the
JSONBnewtype toDatabase.Esqueleto.Internal.JSON - Re-export it in
Database.Esqueleto.PostgreSQL.JSON - Use it in
Database.Esqueleto.PostgreSQL.JSON.Experimental - Be able to also use the
JSONoperators fromDatabase.Esqueleto.PostgreSQL.JSONin values you get when usingDatabase.Esqueleto.PostgreSQL.JSON.Experimental - ???
- profit?
@Vlix that would require anyone using the JSONB type to agree on how it works. If there are any inconsistencies between different implementations then the type would need to be split then. As for reusing the type internally with postgres, it's possible but would require ensuring that the existing operators all work as expected there.