Permalink
Browse files

export ZT wrapper and unwrap in PG backend

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...
1 parent 2455c35 commit b8442b9c3f8804a897b99e70be96b487acb112d9 @rekado rekado committed Jul 24, 2012
Showing with 4 additions and 2 deletions.
  1. +2 −2 persistent-postgresql/Database/Persist/Postgresql.hs
  2. +2 −0 persistent/Database/Persist/Store.hs
@@ -220,7 +220,7 @@ instance PGTF.ToField P where
toField (P (PersistDay d)) = PGTF.toField d
toField (P (PersistTimeOfDay 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 (PersistList l)) = PGTF.toField $ listToJSON l
toField (P (PersistMap m)) = PGTF.toField $ mapToJSON m
@@ -253,7 +253,7 @@ getGetter PG.Varchar = convertPV PersistText
getGetter PG.Date = convertPV PersistDay
getGetter PG.Time = convertPV PersistTimeOfDay
getGetter PG.Timestamp = convertPV PersistUTCTime
-getGetter PG.TimestampWithTimeZone = convertPV PersistZonedTime
+getGetter PG.TimestampWithTimeZone = convertPV (PersistZonedTime . ZT)
getGetter PG.Bit = convertPV PersistInt64
getGetter PG.Varbit = convertPV PersistInt64
getGetter PG.Numeric = convertPV (PersistDouble . fromRational)
@@ -30,6 +30,8 @@ module Database.Persist.Store
, PersistFilter (..)
, SomePersistField (..)
+ , ZT (..) -- ZonedTime wrapper
+
, insertBy
, getByValue
, getJust

0 comments on commit b8442b9

Please sign in to comment.