Skip to content

Commit 28eb8e9

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

+8-1
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,13 @@ 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+
(||.) :: QGenExpr ctxt Postgres s (PgJSONB a)
965+
-> QGenExpr ctxt Postgres s (PgJSONB a)
966+
-> QGenExpr ctxt Postgres s (PgJSONB a)
967+
QExpr a ||. QExpr b =
968+
QExpr (Pg.pgBinOp "||" <$> a <*> b)
969+
963970
-- | Postgres @-@ operator on json objects. Returns the supplied json object
964971
-- with the supplied key deleted. See 'withoutIdx' for the corresponding
965972
-- operator on arrays.

0 commit comments

Comments
 (0)