Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
erikd committed Jul 5, 2020
1 parent f56f1a2 commit 37daaad
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions persistent/Database/Persist/Class/PersistField.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Data.Int (Int8, Int16, Int32, Int64)
import qualified Data.IntMap as IM
import qualified Data.Map as M
import Data.Monoid ((<>))
import Data.Ratio (denominator, numerator)
import qualified Data.Set as S
import Data.Text (Text)
import qualified Data.Text as T
Expand Down Expand Up @@ -230,6 +231,9 @@ instance PersistField Word64 where
toPersistValue = PersistWord64 . fromIntegral
fromPersistValue (PersistWord64 w) = Right $ fromIntegral w
fromPersistValue (PersistInt64 i) = Right $ fromIntegral i
fromPersistValue x@(PersistRational r) = if denominator r == 1
then Right $ fromIntegral (numerator r)
else Left $ fromPersistValueError "Word64" "rational" x
fromPersistValue x = Left $ fromPersistValueError "Word64" "integer" x

instance PersistField Double where
Expand Down

0 comments on commit 37daaad

Please sign in to comment.