Skip to content

Commit

Permalink
export ZT wrapper and unwrap in PG backend
Browse files Browse the repository at this point in the history
To avoid orphan instances of Ord and Eq for the ZonedTime type, a
newtype wrapper is defined in Database.Persist.Store. As
Database.Persist.Postgresql needs to get access to the value inside the
wrapped ZonedTime, the ZT wrapper must be exported by
Database.Persist.Store.
  • Loading branch information
rekado committed Jul 24, 2012
1 parent 2455c35 commit b8442b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions persistent-postgresql/Database/Persist/Postgresql.hs
Expand Up @@ -220,7 +220,7 @@ instance PGTF.ToField P where
toField (P (PersistDay d)) = PGTF.toField d toField (P (PersistDay d)) = PGTF.toField d
toField (P (PersistTimeOfDay t)) = PGTF.toField t toField (P (PersistTimeOfDay t)) = PGTF.toField t
toField (P (PersistUTCTime t)) = PGTF.toField t toField (P (PersistUTCTime t)) = PGTF.toField t
toField (P (PersistZonedTime t)) = PGTF.toField t toField (P (PersistZonedTime (ZT t))) = PGTF.toField t
toField (P PersistNull) = PGTF.toField PG.Null toField (P PersistNull) = PGTF.toField PG.Null
toField (P (PersistList l)) = PGTF.toField $ listToJSON l toField (P (PersistList l)) = PGTF.toField $ listToJSON l
toField (P (PersistMap m)) = PGTF.toField $ mapToJSON m toField (P (PersistMap m)) = PGTF.toField $ mapToJSON m
Expand Down Expand Up @@ -253,7 +253,7 @@ getGetter PG.Varchar = convertPV PersistText
getGetter PG.Date = convertPV PersistDay getGetter PG.Date = convertPV PersistDay
getGetter PG.Time = convertPV PersistTimeOfDay getGetter PG.Time = convertPV PersistTimeOfDay
getGetter PG.Timestamp = convertPV PersistUTCTime getGetter PG.Timestamp = convertPV PersistUTCTime
getGetter PG.TimestampWithTimeZone = convertPV PersistZonedTime getGetter PG.TimestampWithTimeZone = convertPV (PersistZonedTime . ZT)
getGetter PG.Bit = convertPV PersistInt64 getGetter PG.Bit = convertPV PersistInt64
getGetter PG.Varbit = convertPV PersistInt64 getGetter PG.Varbit = convertPV PersistInt64
getGetter PG.Numeric = convertPV (PersistDouble . fromRational) getGetter PG.Numeric = convertPV (PersistDouble . fromRational)
Expand Down
2 changes: 2 additions & 0 deletions persistent/Database/Persist/Store.hs
Expand Up @@ -30,6 +30,8 @@ module Database.Persist.Store
, PersistFilter (..) , PersistFilter (..)
, SomePersistField (..) , SomePersistField (..)


, ZT (..) -- ZonedTime wrapper

, insertBy , insertBy
, getByValue , getByValue
, getJust , getJust
Expand Down

0 comments on commit b8442b9

Please sign in to comment.