beam icon indicating copy to clipboard operation
beam copied to clipboard

Added Postgres specific || operator for concatenating two jsonb values

Open mputz86 opened this issue 5 years ago • 4 comments

I am not sure if the operator naming is correct and if it is ok to introduce these PostgreSQL specific operators like this (not so much experienced in Haskell yet). But anyway, I try my luck and hope at least to get feedback on how to do it correctly :D. Here is the official description of the || jsonb-concatenator operator as well as some more https://www.postgresql.org/docs/11/functions-json.html (maybe I can add some more ;) ). Thank you.

mputz86 avatar May 17 '20 22:05 mputz86

Also got some conflict with the ||. from Database.Beam. So either the operators should be named different than in Postgres or (like now) hiding the one from Database.Beam and let the user import Postgres specific stuff qualified (like I did it :D 🤷‍♂️ ). Dont know what is the right solution here.

mputz86 avatar May 18 '20 20:05 mputz86

Ah good point, I totally forgot that ||. is already taken. Unless you can think of a better operator name that makes sense (I can't), then I'd suggest just giving it a name like pgJsonbConcat.

kmicklas avatar May 19 '20 00:05 kmicklas

Then for me the question is "where" to put it in code:

  • put it close (i.e. maybe at the end of) the pgJsonbABC things or
  • keep it in the order of the Postgres doc (like obviously all the rest is right now) and put it after (?&) but before withoutKey :)

Sry, too much discussion for such a small thing? :D

mputz86 avatar May 20 '20 19:05 mputz86

I don't think it matters much but probably nice to keep the order in line with the Postgres docs where possible.

kmicklas avatar May 21 '20 12:05 kmicklas