Skip to content

Commit 96fe752

Browse files
committed
Added Postgres specific || operator for concatenating two jsonb values
into a new json value.
1 parent ebbb8da commit 96fe752

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

beam-postgres/Database/Beam/Postgres/PgSpecific.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module Database.Beam.Postgres.PgSpecific
3232

3333
, (@>), (<@), (->#), (->$)
3434
, (->>#), (->>$), (#>), (#>>)
35-
, (?), (?|), (?&)
35+
, (?), (?|), (?&), (||.)
3636

3737
, withoutKey, withoutIdx
3838
, withoutKeys
@@ -960,6 +960,14 @@ QExpr a ?| QExpr b =
960960
QExpr a ?& QExpr b =
961961
QExpr (pgBinOp "?&" <$> a <*> b)
962962

963+
-- | Postgres @||@ operator. Concatenates two jsonb values into a new jsonb value.
964+
(||.) ::
965+
QGenExpr ctxt Pg.Postgres s (Pg.PgJSONB a) ->
966+
QGenExpr ctxt Pg.Postgres s (Pg.PgJSONB a) ->
967+
QGenExpr ctxt Pg.Postgres s (Pg.PgJSONB a)
968+
QExpr a ||. QExpr b =
969+
QExpr (Pg.pgBinOp "||" <$> a <*> b)
970+
963971
-- | Postgres @-@ operator on json objects. Returns the supplied json object
964972
-- with the supplied key deleted. See 'withoutIdx' for the corresponding
965973
-- operator on arrays.

0 commit comments

Comments
 (0)