@@ -85,6 +85,7 @@ import qualified Generics.SOP as SOP
8585
8686-- $setup
8787-- >>> import Squeal.PostgreSQL
88+-- >>> import Data.Aeson
8889
8990{-----------------------------------------
9091 -- json and jsonb support
@@ -379,58 +380,64 @@ jsonbPretty :: null 'PGjsonb :--> null 'PGtext
379380jsonbPretty = unsafeFunction "jsonb_pretty"
380381
381382
382−-- | Expands the outermost JSON object into a set of key/value pairs.
383−-- >>> import Data.Aeson
384−-- >>> printSQL (select Star (from (jsonEach (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))
385−-- SELECT * FROM json_each(('{"a":"foo","b":"bar"}' :: json))
383+{- | Expands the outermost JSON object into a set of key/value pairs.
384+
385+>>> printSQL (select Star (from (jsonEach (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))
386+SELECT * FROM json_each(('{"a":"foo","b":"bar"}' :: json))
387+-}
386388jsonEach :: SetOfFunction "json_each" (null 'PGjson)
387389 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]
388−jsonEach = unsafeSetOfFunction #json_each
390+jsonEach = unsafeSetOfFunction
389391
390−-- | Expands the outermost binary JSON object into a set of key/value pairs.
391−-- >>> import Data.Aeson
392−-- >>> printSQL (select Star (from (jsonbEach (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))
393−-- SELECT * FROM jsonb_each(('{"a":"foo","b":"bar"}' :: jsonb))
392+{- | Expands the outermost binary JSON object into a set of key/value pairs.
393+
394+>>> printSQL (select Star (from (jsonbEach (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))
395+SELECT * FROM jsonb_each(('{"a":"foo","b":"bar"}' :: jsonb))
396+-}
394397jsonbEach
395398 :: SetOfFunction "jsonb_each" (nullity 'PGjsonb)
396399 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]
397−jsonbEach = unsafeSetOfFunction #jsonb_each
400+jsonbEach = unsafeSetOfFunction
398401
399−-- | Expands the outermost JSON object into a set of key/value pairs.-- | Expands the outermost binary JSON object into a set of key/value pairs.
400−-- >>> import Data.Aeson
401−-- >>> printSQL (select Star (from (jsonEachText (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))
402−-- SELECT * FROM json_each_text(('{"a":"foo","b":"bar"}' :: json))
402+{- | Expands the outermost JSON object into a set of key/value pairs.
403+
404+>>> printSQL (select Star (from (jsonEachText (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))
405+SELECT * FROM json_each_text(('{"a":"foo","b":"bar"}' :: json))
406+-}
403407jsonEachText
404408 :: SetOfFunction "json_each_text" (null 'PGjson)
405409 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]
406−jsonEachText = unsafeSetOfFunction #json_each_text
410+jsonEachText = unsafeSetOfFunction
407411
408−-- | Expands the outermost binary JSON object into a set of key/value pairs.
409−-- >>> import Data.Aeson
410−-- >>> printSQL (select Star (from (jsonbEachText (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))
411−-- SELECT * FROM jsonb_each_text(('{"a":"foo","b":"bar"}' :: jsonb))
412+{- | Expands the outermost binary JSON object into a set of key/value pairs.
413+
414+>>> printSQL (select Star (from (jsonbEachText (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))
415+SELECT * FROM jsonb_each_text(('{"a":"foo","b":"bar"}' :: jsonb))
416+-}
412417jsonbEachText
413418 :: SetOfFunction "jsonb_each_text" (null 'PGjsonb)
414419 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]
415−jsonbEachText = unsafeSetOfFunction #jsonb_each_text
420+jsonbEachText = unsafeSetOfFunction
416421
417−-- | Returns set of keys in the outermost JSON object.
418−-- >>> import Data.Aeson
419−-- >>> printSQL (jsonObjectKeys (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))
420−-- json_object_keys(('{"a":"foo","b":"bar"}' :: json))
422+{- | Returns set of keys in the outermost JSON object.
423+
424+>>> printSQL (jsonObjectKeys (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))
425+json_object_keys(('{"a":"foo","b":"bar"}' :: json))
426+-}
421427jsonObjectKeys
422428 :: SetOfFunction "json_object_keys" (nullity 'PGjson)
423429 '["json_object_keys" ::: 'NotNull 'PGtext]
424−jsonObjectKeys = unsafeSetOfFunction #json_object_keys
430+jsonObjectKeys = unsafeSetOfFunction
425431
426−-- | Returns set of keys in the outermost JSON object.
427−-- >>> import Data.Aeson
428−-- >>> printSQL (jsonbObjectKeys (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))
429−-- jsonb_object_keys(('{"a":"foo","b":"bar"}' :: jsonb))
432+{- | Returns set of keys in the outermost JSON object.
433+
434+>>> printSQL (jsonbObjectKeys (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))
435+jsonb_object_keys(('{"a":"foo","b":"bar"}' :: jsonb))
436+-}
430437jsonbObjectKeys
431438 :: SetOfFunction "jsonb_object_keys" (null 'PGjsonb)
432439 '["jsonb_object_keys" ::: 'NotNull 'PGtext]
433−jsonbObjectKeys = unsafeSetOfFunction #jsonb_object_keys
440+jsonbObjectKeys = unsafeSetOfFunction
434441
435442unsafePopulateFunction
436443 :: forall fun schemas null outer commons params ty row