git.iko.soy/typeable/postgresql-simple
on master help sign in
Implement and export parseHStoreList

Closes #132

commit5295b740b00e536af888dce5fe0ef7a8939c3f60 authorLeon P Smith <leon@melding-monads.com> dateMon 24 Nov 2014, 17:42 (12 years ago) parentbcbacfe
2 files changed+8
src/Database/PostgreSQL/Simple/HStore.hs+1 src/Database/PostgreSQL/Simple/HStore/Implementation.hs+7
src/Database/PostgreSQL/Simple/HStore.hs+1
@@ -28,6 +28,7 @@ module Database.PostgreSQL.Simple.HStore
2828 , toBuilder
2929 , toLazyByteString
3030 , hstore
31+ , parseHStoreList
3132 , ToHStoreText(..)
3233 , HStoreText
3334 ) where
src/Database/PostgreSQL/Simple/HStore/Implementation.hs+7
@@ -154,6 +154,13 @@ instance FromField HStoreMap where
154154 fromField f mdat = convert <$> fromField f mdat
155155 where convert (HStoreList xs) = HStoreMap (Map.fromList xs)
156156
157+parseHStoreList :: BS.ByteString -> Either String HStoreList
158+parseHStoreList dat =
159+ case P.parseOnly (parseHStore <* P.endOfInput) dat of
160+ Left err -> Left (show err)
161+ Right (Left err) -> Left (show err)
162+ Right (Right val) -> Right val
163+
157164parseHStore :: P.Parser (Either UnicodeException HStoreList)
158165parseHStore = do
159166 kvs <- P.sepBy' (skipWhiteSpace *> parseHStoreKeyVal)