postgresql-simple 0.4.5.0 → 0.4.6.0
raw patch · 4 files changed
+20/−3 lines, 4 files
Files
- postgresql-simple.cabal +2/−2
- src/Database/PostgreSQL/Simple/Time.hs +1/−0
- src/Database/PostgreSQL/Simple/Time/Implementation.hs +11/−0
- src/Database/PostgreSQL/Simple/ToField.hs +6/−1
postgresql-simple.cabal view
@@ -1,5 +1,5 @@ Name: postgresql-simple-Version: 0.4.5.0+Version: 0.4.6.0 Synopsis: Mid-Level PostgreSQL client library Description: Mid-Level PostgreSQL client library, forked from mysql-simple.@@ -81,7 +81,7 @@ source-repository this type: git location: http://github.com/lpsmith/postgresql-simple- tag: v0.4.5.0+ tag: v0.4.6.0 test-suite test type: exitcode-stdio-1.0
src/Database/PostgreSQL/Simple/Time.hs view
@@ -75,6 +75,7 @@ , zonedTimestampToBuilder , localTimestampToBuilder , unboundedToBuilder+ , nominalDiffTimeToBuilder ) where import Database.PostgreSQL.Simple.Time.Implementation
src/Database/PostgreSQL/Simple/Time/Implementation.hs view
@@ -229,6 +229,17 @@ dateToBuilder :: Date -> Builder dateToBuilder = unboundedToBuilder dayToBuilder +nominalDiffTimeToBuilder :: NominalDiffTime -> Builder+nominalDiffTimeToBuilder xyz+ | yz < 500000 = sign ++ integral x+ | otherwise = sign ++ integral x ++ fromChar '.' ++ showD6 y+ where+ -- A kludge to work around the fact that Data.Fixed isn't very fast and+ -- doesn't give me access to the MkFixed constructor.+ sign = if xyz >= 0 then mempty else fromChar '-'+ (x,yz) = ((unsafeCoerce (abs xyz) :: Integer) + 500000) `quotRem` 1000000000000+ (fromIntegral -> y, _z) = yz `quotRem` 1000000+ showSeconds :: Pico -> Builder showSeconds xyz | yz == 0 = pad2 x
src/Database/PostgreSQL/Simple/ToField.hs view
@@ -30,7 +30,7 @@ import Data.Int (Int8, Int16, Int32, Int64) import Data.List (intersperse) import Data.Monoid (mappend)-import Data.Time (Day, TimeOfDay, LocalTime, UTCTime, ZonedTime)+import Data.Time (Day, TimeOfDay, LocalTime, UTCTime, ZonedTime, NominalDiffTime) import Data.Typeable (Typeable) import Data.Word (Word, Word8, Word16, Word32, Word64) import {-# SOURCE #-} Database.PostgreSQL.Simple.ToRow@@ -225,6 +225,7 @@ toField = toField . LT.toStrict {-# INLINE toField #-} + instance ToField UTCTime where toField = Plain . inQuotes . utcTimeToBuilder {-# INLINE toField #-}@@ -259,6 +260,10 @@ instance ToField Date where toField = Plain . inQuotes . dateToBuilder+ {-# INLINE toField #-}++instance ToField NominalDiffTime where+ toField = Plain . inQuotes . nominalDiffTimeToBuilder {-# INLINE toField #-} instance (ToField a) => ToField (PGArray a) where