@@ -128,6 +128,11 @@ module Squeal.PostgreSQL.Expression
128 , jsonbObjectKeys
128 , jsonbObjectKeys
129 , jsonTypeof
129 , jsonTypeof
130 , jsonbTypeof
130 , jsonbTypeof
131 -- ** Aggregation
136 -- ** Aggregation
132 , unsafeAggregate, unsafeAggregateDistinct
137 , unsafeAggregate, unsafeAggregateDistinct
133 , sum_, sumDistinct
138 , sum_, sumDistinct
@@ -1171,7 +1176,7 @@ jsonbArrayLength = unsafeFunction "jsonb_array_length"
1172-- | Returns JSON value pointed to by path_elems (equivalent to #> operator).
1177-- | Returns JSON value pointed to by path_elems (equivalent to #> operator).
1173jsonExtractPath
1178jsonExtractPath
1174− :: SListI elems
1179+ :: SListI elems
1175 => Expression schema relations grouping params (nullity 'PGjson)
1180 => Expression schema relations grouping params (nullity 'PGjson)
1176 -> NP (Expression schema relations grouping params) elems
1181 -> NP (Expression schema relations grouping params) elems
1177 -> Expression schema relations grouping params (nullity 'PGjsonb)
1182 -> Expression schema relations grouping params (nullity 'PGjsonb)
@@ -1180,7 +1185,7 @@ jsonExtractPath x xs =
1181-- | Returns JSON value pointed to by path_elems (equivalent to #> operator).
1186-- | Returns JSON value pointed to by path_elems (equivalent to #> operator).
1182jsonbExtractPath
1187jsonbExtractPath
1183− :: SListI elems
1188+ :: SListI elems
1184 => Expression schema relations grouping params (nullity 'PGjsonb)
1189 => Expression schema relations grouping params (nullity 'PGjsonb)
1185 -> NP (Expression schema relations grouping params) elems
1190 -> NP (Expression schema relations grouping params) elems
1186 -> Expression schema relations grouping params (nullity 'PGjsonb)
1191 -> Expression schema relations grouping params (nullity 'PGjsonb)
@@ -1190,17 +1195,17 @@ jsonbExtractPath x xs =
1190-- | Returns JSON value pointed to by path_elems (equivalent to #> operator),
1195-- | Returns JSON value pointed to by path_elems (equivalent to #> operator),
1191-- as text.
1196-- as text.
1192jsonExtractPathAsText
1197jsonExtractPathAsText
1193− :: SListI elems
1198+ :: SListI elems
1194 => Expression schema relations grouping params (nullity 'PGjson)
1199 => Expression schema relations grouping params (nullity 'PGjson)
1195 -> NP (Expression schema relations grouping params) elems
1200 -> NP (Expression schema relations grouping params) elems
1196− -> Expression schema relations grouping params (nullity 'PGjsonb)
1201+ -> Expression schema relations grouping params (nullity 'PGjson)
1197jsonExtractPathAsText x xs =
1202jsonExtractPathAsText x xs =
1198 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1203 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1200-- | Returns JSON value pointed to by path_elems (equivalent to #> operator),
1205-- | Returns JSON value pointed to by path_elems (equivalent to #> operator),
1201-- as text.
1206-- as text.
1202jsonbExtractPathAsText
1207jsonbExtractPathAsText
1203− :: SListI elems
1208+ :: SListI elems
1204 => Expression schema relations grouping params (nullity 'PGjsonb)
1209 => Expression schema relations grouping params (nullity 'PGjsonb)
1205 -> NP (Expression schema relations grouping params) elems
1210 -> NP (Expression schema relations grouping params) elems
1206 -> Expression schema relations grouping params (nullity 'PGjsonb)
1211 -> Expression schema relations grouping params (nullity 'PGjsonb)
@@ -1233,6 +1238,63 @@ jsonbTypeof
1233 -> Expression schema relations grouping params (nullity 'PGtext)
1238 -> Expression schema relations grouping params (nullity 'PGtext)
1234jsonbTypeof = unsafeFunction "jsonb_typeof"
1239jsonbTypeof = unsafeFunction "jsonb_typeof"
1241+-- | Returns its argument with all object fields that have null values omitted.
1242+-- Other null values are untouched.
1244+ :: Expression schema relations grouping params (nullity 'PGjson)
1245+ -> Expression schema relations grouping params (nullity 'PGjson)
1246+jsonStripNulls = unsafeFunction "json_strip_nulls"
1248+-- | Returns its argument with all object fields that have null values omitted.
1249+-- Other null values are untouched.
1251+ :: Expression schema relations grouping params (nullity 'PGjsonb)
1252+ -> Expression schema relations grouping params (nullity 'PGjsonb)
1253+jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1255+-- | @ jsonbSet target path new_value create_missing @
1257+-- Returns target with the section designated by path replaced by new_value,
1258+-- or with new_value added if create_missing is true ( default is true) and the
1259+-- item designated by path does not exist. As with the path orientated
1260+-- operators, negative integers that appear in path count from the end of JSON
1263+ :: PGtextArray "jsonbSet" arr
1264+ => Expression schema relations grouping params (nullity 'PGjsonb)
1265+ -> Expression schema relations grouping params (nullity arr)
1266+ -> Expression schema relations grouping params (nullity 'PGjsonb)
1267+ -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1268+ -> Expression schema relations grouping params (nullity 'PGjsonb)
1269+jsonbSet tgt path val createMissing = case createMissing of
1270+ Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1271+ Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1273+-- | @ jsonbInsert target path new_value insert_after @
1275+-- Returns target with new_value inserted. If target section designated by
1276+-- path is in a JSONB array, new_value will be inserted before target or after
1277+-- if insert_after is true (default is false). If target section designated by
1278+-- path is in JSONB object, new_value will be inserted only if target does not
1279+-- exist. As with the path orientated operators, negative integers that appear
1280+-- in path count from the end of JSON arrays.
1282+ :: PGtextArray "jsonbInsert" arr
1283+ => Expression schema relations grouping params (nullity 'PGjsonb)
1284+ -> Expression schema relations grouping params (nullity arr)
1285+ -> Expression schema relations grouping params (nullity 'PGjsonb)
1286+ -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1287+ -> Expression schema relations grouping params (nullity 'PGjsonb)
1288+jsonbInsert tgt path val insertAfter = case insertAfter of
1289+ Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1290+ Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1292+-- | Returns its argument as indented JSON text.
1294+ :: Expression schema relations grouping params (nullity 'PGjsonb)
1295+ -> Expression schema relations grouping params (nullity 'PGtext)
1296+jsonbPretty = unsafeFunction "jsonb_pretty"
1236{-----------------------------------------
1298{-----------------------------------------
1237aggregation
1299aggregation
1238-----------------------------------------}
1300-----------------------------------------}