git.iko.soy/typeable/postgresql-simple
on master help sign in
Implement and export parseHStoreList
5295b74Leon P Smith
src/Database/PostgreSQL/Simple/HStore.hs+1
@@ -28,6 +28,7 @@ module Database.PostgreSQL.Simple.HStore
28 , toBuilder
28 , toBuilder
29 , toLazyByteString
29 , toLazyByteString
30 , hstore
30 , hstore
31+ , parseHStoreList
31 , ToHStoreText(..)
32 , ToHStoreText(..)
32 , HStoreText
33 , HStoreText
33 ) where
34 ) where
src/Database/PostgreSQL/Simple/HStore/Implementation.hs+7
@@ -154,6 +154,13 @@ instance FromField HStoreMap where
154 fromField f mdat = convert <$> fromField f mdat
154 fromField f mdat = convert <$> fromField f mdat
155 where convert (HStoreList xs) = HStoreMap (Map.fromList xs)
155 where convert (HStoreList xs) = HStoreMap (Map.fromList xs)
156
156
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+
157parseHStore :: P.Parser (Either UnicodeException HStoreList)
164parseHStore :: P.Parser (Either UnicodeException HStoreList)
158parseHStore = do
165parseHStore = do
159 kvs <- P.sepBy' (skipWhiteSpace *> parseHStoreKeyVal)
166 kvs <- P.sepBy' (skipWhiteSpace *> parseHStoreKeyVal)