packages feed

opaleye 0.7.6.1 → 0.7.6.2

raw patch · 5 files changed

+34/−18 lines, 5 filesdep ~semigroupsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: semigroups

API changes (from Hackage documentation)

- Opaleye.Internal.PGTypes: unsafePgFormatTime :: FormatTime t => Name -> String -> t -> Column c
+ Opaleye.Internal.PGTypes: unsafePgFormatTime :: ISO8601 t => Name -> t -> Column c

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.7.6.2++Fix ISO 8601 date fomatting.  Thanks to Michal @kozak.+ ## 0.7.6.1  No user-visible changes
Test/Test.hs view
@@ -1238,6 +1238,11 @@ testLiterals :: Test testLiterals = do   let testLiteral fn value = testH (pure (fn value)) (`shouldBe` [value])+      exampleDate = Time.fromGregorian 2018 11 29+      exampleTime = Time.TimeOfDay 11 22 33+      exampleUTCTime = Time.UTCTime exampleDate (Time.sinceMidnight exampleTime)+      exampleDatePadded = Time.fromGregorian 18 11 29+      exampleUTCTimePadded = Time.UTCTime exampleDatePadded (Time.sinceMidnight exampleTime)   it "sqlString" $ testLiteral O.sqlString "Hello"   it "sqlLazyByteString" $ testLiteral O.sqlLazyByteString "Hello"   it "sqlNumeric" $ testLiteral O.sqlNumeric 3.14159@@ -1246,13 +1251,21 @@   it "sqlDouble" $ testLiteral O.sqlDouble 3.14   it "sqlBool" $ testLiteral O.sqlBool True   it "sqlUUID" $ testLiteral O.sqlUUID (read "c2cc10e1-57d6-4b6f-9899-38d972112d8c")-  it "sqlDay" $ testLiteral O.sqlDay (read "2018-11-29")-  it "sqlUTCTime" $ testLiteral O.sqlUTCTime (read "2018-11-29 11:22:33 UTC")-  it "sqlLocalTime" $ testLiteral O.sqlLocalTime (read "2018-11-29 11:22:33")+  it "sqlDay" $ testLiteral O.sqlDay exampleDate+  it "sqlDayPadded" $ testLiteral O.sqlDay exampleDatePadded+  it "sqlUTCTime" $ testLiteral O.sqlUTCTime exampleUTCTime+  it "sqlUTCTimePadded" $ testLiteral O.sqlUTCTime exampleUTCTimePadded+  it "sqlLocalTime" $ testLiteral O.sqlLocalTime (Time.LocalTime exampleDate exampleTime)+  it "sqlLocalTimePadded" $ testLiteral O.sqlLocalTime (Time.LocalTime exampleDatePadded exampleTime)    -- ZonedTime has no Eq instance, so we compare on the result of 'zonedTimeToUTC'   it "sqlZonedTime" $-    let value = read "2018-11-29 11:22:33 UTC" :: Time.ZonedTime in+    let value = Time.utcToZonedTime Time.utc exampleUTCTime in+    testH (pure (O.sqlZonedTime value))+          (\r -> map Time.zonedTimeToUTC r `shouldBe` [Time.zonedTimeToUTC value])++  it "sqlZonedTimePadded" $+    let value = Time.utcToZonedTime Time.utc exampleUTCTimePadded in     testH (pure (O.sqlZonedTime value))           (\r -> map Time.zonedTimeToUTC r `shouldBe` [Time.zonedTimeToUTC value]) 
opaleye.cabal view
@@ -1,6 +1,6 @@ name:            opaleye copyright:       Copyright (c) 2014-2018 Purely Agile Limited; 2019-2021 Tom Ellis-version:         0.7.6.1+version:         0.7.6.2 synopsis:        An SQL-generating DSL targeting PostgreSQL description:     An SQL-generating DSL targeting PostgreSQL.  Allows                  Postgres queries to be written within Haskell in a
src/Opaleye/Internal/PGTypes.hs view
@@ -13,12 +13,13 @@ import qualified Data.Text.Lazy.Encoding as LTextEncoding import qualified Data.ByteString as SByteString import qualified Data.ByteString.Lazy as LByteString-import qualified Data.Time.Compat as Time-import qualified Data.Time.Locale.Compat as Locale+import qualified Data.Time.Format.ISO8601.Compat as Time -unsafePgFormatTime :: Time.FormatTime t => HPQ.Name -> String -> t -> Column c-unsafePgFormatTime typeName formatString = castToType typeName . format-  where format = Time.formatTime Locale.defaultTimeLocale formatString+unsafePgFormatTime :: Time.ISO8601 t => HPQ.Name -> t -> Column c+unsafePgFormatTime typeName = castToType typeName . format+    where+      format  = quote . Time.iso8601Show+      quote s = "'" ++ s ++ "'"  literalColumn :: forall a. IsSqlType a => HPQ.Literal -> Column a literalColumn = Column . HPQ.CastExpr (showSqlType (Proxy :: Proxy a)) . HPQ.ConstExpr
src/Opaleye/Internal/PGTypesExternal.hs view
@@ -102,27 +102,25 @@ pgUUID = IPT.literalColumn . HPQ.StringLit . UUID.toString  pgDay :: Time.Day -> Column PGDate-pgDay = IPT.unsafePgFormatTime "date" "'%F'"+pgDay = IPT.unsafePgFormatTime "date"  pgUTCTime :: Time.UTCTime -> Column PGTimestamptz-pgUTCTime = IPT.unsafePgFormatTime "timestamptz" "'%FT%T%QZ'"+pgUTCTime = IPT.unsafePgFormatTime "timestamptz"  pgLocalTime :: Time.LocalTime -> Column PGTimestamp-pgLocalTime = IPT.unsafePgFormatTime "timestamp" "'%FT%T%Q'"+pgLocalTime = IPT.unsafePgFormatTime "timestamp"  pgZonedTime :: Time.ZonedTime -> Column PGTimestamptz-pgZonedTime = IPT.unsafePgFormatTime "timestamptz" "'%FT%T%Q%z'"+pgZonedTime = IPT.unsafePgFormatTime "timestamptz"  pgTimeOfDay :: Time.TimeOfDay -> Column PGTime-pgTimeOfDay = IPT.unsafePgFormatTime "time" "'%T%Q'"+pgTimeOfDay = IPT.unsafePgFormatTime "time"  -- "We recommend not using the type time with time zone" -- http://www.postgresql.org/docs/8.3/static/datatype-datetime.html  sqlInterval :: Time.CalendarDiffTime -> Column PGInterval-sqlInterval = IPT.castToType "interval" . quote . Time.Format.ISO8601.iso8601Show-    where-      quote s = "'" ++ s ++ "'"+sqlInterval = IPT.unsafePgFormatTime "interval"  pgCiStrictText :: CI.CI SText.Text -> Column PGCitext pgCiStrictText = IPT.literalColumn . HPQ.StringLit . SText.unpack . CI.original