esqueleto icon indicating copy to clipboard operation
esqueleto copied to clipboard

Add new Postgresql.JSON.Experimental

Open belevy opened this issue 4 years ago • 6 comments

#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 toJsonb function on Value, Entity, and tuples therof (up to 8)

Before submitting your PR, check that you've:

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).

belevy avatar Sep 12 '21 15:09 belevy

@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 avatar Nov 03 '21 14:11 belevy

@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.

Vlix avatar Mar 10 '22 23:03 Vlix

I still don't see why the JSONB newtype isn't used?

  • Move the JSONB newtype to Database.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 JSON operators from Database.Esqueleto.PostgreSQL.JSON in values you get when using Database.Esqueleto.PostgreSQL.JSON.Experimental
  • ???
  • profit?

Vlix avatar Oct 20 '23 07:10 Vlix

@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.

belevy avatar Dec 26 '23 20:12 belevy