Rename function to get maybe record from SQL.

This commit is contained in:
Kei Hibino 2013-05-18 09:48:27 +09:00
parent 7c1598d85b
commit 53e20120b2

View File

@ -18,7 +18,7 @@ module Database.Record.FromSql (
(<&>), (<&>),
outer, maybeRecord,
FromSql (recordFromSql), recordFromSql', FromSql (recordFromSql), recordFromSql',
takeRecord, toRecord, takeRecord, toRecord,
@ -68,11 +68,11 @@ a <&> b = (,) <$> a <*> b
infixl 4 <&> infixl 4 <&>
outer :: PersistableType q maybeRecord :: PersistableType q
=> RecordFromSql q a => RecordFromSql q a
-> KeyConstraint NotNull a -> KeyConstraint NotNull a
-> RecordFromSql q (Maybe a) -> RecordFromSql q (Maybe a)
outer rec pkey = createRecordFromSql mayToRec where maybeRecord rec pkey = createRecordFromSql mayToRec where
mayToRec vals mayToRec vals
| vals !! index pkey /= Persistable.sqlNullValue = (Just a, vals') | vals !! index pkey /= Persistable.sqlNullValue = (Just a, vals')
| otherwise = (Nothing, vals') where | otherwise = (Nothing, vals') where
@ -90,7 +90,7 @@ instance (FromSql q a, FromSql q b) => FromSql q (a, b) where
instance (HasKeyConstraint NotNull a, FromSql q a, PersistableType q) instance (HasKeyConstraint NotNull a, FromSql q a, PersistableType q)
=> FromSql q (Maybe a) where => FromSql q (Maybe a) where
recordFromSql = outer recordFromSql $ keyConstraint recordFromSql = maybeRecord recordFromSql keyConstraint
instance FromSql q () where instance FromSql q () where
recordFromSql = recordFromSql' recordFromSql = recordFromSql'