git.iko.soy/typeable/postgresql-simple
on master help sign in
Parse NULL values in arrays correctly.
commit84bf0b47d5c234df2f6e079fb565a27bba9b8b1f authorFrancesco Mazzoli <francesco.mazzoli@erudify.com> dateWed 12 Mar 2014, 17:05 (13 years ago) parentc29effe
1 file changed+7−3
src/Database/PostgreSQL/Simple/FromField.hs+7−3
src/Database/PostgreSQL/Simple/FromField.hs+7−3
@@ -444,9 +444,13 @@ fromArray typeInfo f = sequence . (parseIt <$>) <$> array delim
444444 where
445445 delim = typdelim (typelem typeInfo)
446446 fElem = f{ typeOid = typoid (typelem typeInfo) }
447− parseIt item = (fromField f' . Just . fmt delim) item
448− where f' | Arrays.Array _ <- item = f
449− | otherwise = fElem
447+
448+ parseIt item =
449+ fromField f' $ if item' == "NULL" then Nothing else Just item'
450+ where
451+ item' = fmt delim item
452+ f' | Arrays.Array _ <- item = f
453+ | otherwise = fElem
450454
451455instance (FromField a, Typeable a) => FromField (Vector a) where
452456 fromField f v = V.fromList . fromPGArray <$> fromField f v