git.iko.soy/typeable/postgresql-simple
on master help sign in
Merge pull request #102 from bitonic/fix-array-parsing

Parse NULL values in arrays correctly.

commitdbd60f82462ad5f2bd19318c38ffd8ed1e3ea006 authorLeon P Smith <leon@melding-monads.com> dateWed 12 Mar 2014, 12:29 (13 years ago) parentc29effe84bf0b4
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