on dev help sign in
generalize json lit functions
8bac7f4Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+14−7
@@ -88,12 +88,13 @@ module Squeal.PostgreSQL.Expression
88 , upper
88 , upper
89 , charLength
89 , charLength
90 , like
90 , like
91+ -- ** Json functions and operators
91− -- ** json or jsonb operators
92+ -- *** Json and Jsonb operators
92 , (.->)
93 , (.->)
93 , (.->>)
94 , (.->>)
94 , (.#>)
95 , (.#>)
95 , (.#>>)
96 , (.#>>)
96− -- *** jsonb only operators
97+ -- *** Additional Jsonb operators
97 , (.@>)
98 , (.@>)
98 , (.<@)
99 , (.<@)
99 , (.?)
100 , (.?)
@@ -101,7 +102,7 @@ module Squeal.PostgreSQL.Expression
101 , (.?&)
102 , (.?&)
102 , (.-.)
103 , (.-.)
103 , (#-.)
104 , (#-.)
104− -- *** Functions
105+ -- *** Json creation functions
105 , jsonLit
106 , jsonLit
106 , jsonbLit
107 , jsonbLit
107 , toJson
108 , toJson
@@ -1072,12 +1073,18 @@ Table 9.45: JSON creation functions
1072-----------------------------------------}
1073-----------------------------------------}
1073
1074
1074-- | Literal binary JSON
1075-- | Literal binary JSON
1076+jsonbLit
1077+ :: JSON.ToJSON x
1075−jsonbLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjsonb)
1078+ => x -> Expression schema from grouping params (nullity 'PGjsonb)
1079+jsonbLit = cast jsonb . UnsafeExpression
1076−jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1080+ . singleQuotedUtf8 . toStrict . JSON.encode
1077
1081
1078-- | Literal JSON
1082-- | Literal JSON
1083+jsonLit
1084+ :: JSON.ToJSON x
1079−jsonLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjson)
1085+ => x -> Expression schema from grouping params (nullity 'PGjson)
1086+jsonLit = cast json . UnsafeExpression
1080−jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1087+ . singleQuotedUtf8 . toStrict . JSON.encode
1081
1088
1082-- | Returns the value as json. Arrays and composites are converted
1089-- | Returns the value as json. Arrays and composites are converted
1083-- (recursively) to arrays and objects; otherwise, if there is a cast from the
1090-- (recursively) to arrays and objects; otherwise, if there is a cast from the