git.iko.soy/typeable/postgresql-simple
on master help sign in
Merge pull request #89 from TripShot/to-encoding

Optimize `toJSONField` to use `ToJSON.toEncoding`

commit82426e16d7860b49138a7532dedafa3a504bc41c authorOleg Grenrus <oleg.grenrus@iki.fi> dateSat 23 Apr 2022, 14:59 (4 years ago) parentf74cf19da248e5
1 file changed+2−3
src/Database/PostgreSQL/Simple/ToField.hs+2−3
src/Database/PostgreSQL/Simple/ToField.hs+2−3
@@ -318,14 +318,13 @@ instance ToField UUID where
318318instance ToField JSON.Value where
319319 toField = toField . JSON.encode
320320
321−-- | Convert a Haskell value to a JSON 'JSON.Value' using
322−-- 'JSON.toJSON' and convert that to a field using 'toField'.
321+-- | Convert a Haskell value to JSON using 'JSON.toEncoding'.
323322--
324323-- This can be used as the default implementation for the 'toField'
325324-- method for Haskell types that have a JSON representation in
326325-- PostgreSQL.
327326toJSONField :: JSON.ToJSON a => a -> Action
328−toJSONField = toField . JSON.toJSON
327+toJSONField = toField . JSON.encode
329328
330329-- | Surround a string with single-quote characters: \"@'@\"
331330--