on dev help sign in
generalize json lit functions
commit8bac7f4c8bc8badf7fb3bdcf45890aa4fbc7890f authorEitan Chatav <eitan.chatav@gmail.com> dateFri 31 Aug 2018, 18:09 (8 years ago) parentdc05f26
1 file changed+14−7
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+14−7
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+14−7
@@ -88,12 +88,13 @@ module Squeal.PostgreSQL.Expression
8888 , upper
8989 , charLength
9090 , like
91− -- ** json or jsonb operators
91+ -- ** Json functions and operators
92+ -- *** Json and Jsonb operators
9293 , (.->)
9394 , (.->>)
9495 , (.#>)
9596 , (.#>>)
96− -- *** jsonb only operators
97+ -- *** Additional Jsonb operators
9798 , (.@>)
9899 , (.<@)
99100 , (.?)
@@ -101,7 +102,7 @@ module Squeal.PostgreSQL.Expression
101102 , (.?&)
102103 , (.-.)
103104 , (#-.)
104− -- *** Functions
105+ -- *** Json creation functions
105106 , jsonLit
106107 , jsonbLit
107108 , toJson
@@ -1072,12 +1073,18 @@ Table 9.45: JSON creation functions
10721073-----------------------------------------}
10731074
10741075-- | Literal binary JSON
1075−jsonbLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjsonb)
1076−jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1076+jsonbLit
1077+ :: JSON.ToJSON x
1078+ => x -> Expression schema from grouping params (nullity 'PGjsonb)
1079+jsonbLit = cast jsonb . UnsafeExpression
1080+ . singleQuotedUtf8 . toStrict . JSON.encode
10771081
10781082-- | Literal JSON
1079−jsonLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjson)
1080−jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1083+jsonLit
1084+ :: JSON.ToJSON x
1085+ => x -> Expression schema from grouping params (nullity 'PGjson)
1086+jsonLit = cast json . UnsafeExpression
1087+ . singleQuotedUtf8 . toStrict . JSON.encode
10811088
10821089-- | Returns the value as json. Arrays and composites are converted
10831090-- (recursively) to arrays and objects; otherwise, if there is a cast from the