packages feed

odbc 0.1.0 → 0.1.1

raw patch · 4 files changed

+23/−11 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

odbc.cabal view
@@ -5,7 +5,7 @@              suite runs on OS X, Windows and Linux. copyright: FP Complete 2018 maintainer: chrisdone@fpcomplete.com-version:             0.1.0+version:             0.1.1 license:             BSD3 license-file:        LICENSE build-type:          Simple
src/Database/ODBC/Internal.hs view
@@ -512,7 +512,7 @@                     (FloatValue . (realToFrac :: Double -> Float))                     (peek floatPtr)                 pure (Just d))-     | colType == sql_decimal ->+     | colType == sql_numeric || colType == sql_decimal ->        withMalloc          (\floatPtr -> do             mlen <-@@ -1022,8 +1022,8 @@ sql_char :: SQLSMALLINT sql_char = 1 --- sql_numeric :: SQLSMALLINT--- sql_numeric = 2+sql_numeric :: SQLSMALLINT+sql_numeric = 2  sql_decimal :: SQLSMALLINT sql_decimal = 3
src/Database/ODBC/SQLServer.hs view
@@ -233,7 +233,7 @@ instance IsString Part where   fromString = TextPart . T.pack --- The 'LocalTime' type has more accuracy than the @datetime@ type and+-- | The 'LocalTime' type has more accuracy than the @datetime@ type and -- the @datetime2@ types can hold; so you will lose precision when you -- insert. Use this type to indicate that you are aware of the -- precision loss and fine with it.@@ -246,7 +246,7 @@   { unDatetime2 :: LocalTime   } deriving (Eq, Ord, Show, Typeable, Generic, Data, FromValue) --- Use this type to discard higher precision than seconds in your+-- | Use this type to discard higher precision than seconds in your -- 'LocalTime' values for a schema using @smalldatetime@. -- -- <https://docs.microsoft.com/en-us/sql/t-sql/data-types/smalldatetime-transact-sql?view=sql-server-2017>@@ -363,9 +363,12 @@   toSql = toSql . LocalTimeValue . unDatetime2  -- | Corresponds to SMALLDATETIME type of SQL Server. Precision up to--- seconds, nothing smaller.+-- minutes. Consider the seconds field always 0. instance ToSql Smalldatetime where-  toSql = toSql . LocalTimeValue . unSmalldatetime+  toSql = toSql . LocalTimeValue . shrink . unSmalldatetime+    where+      shrink (LocalTime dd (TimeOfDay hh mm _ss)) =+        LocalTime dd (TimeOfDay hh mm 0)  -------------------------------------------------------------------------------- -- Top-level functions
test/Main.hs view
@@ -140,14 +140,15 @@         roundtrip @Int "minBound(Int16)" "Int" "smallint" (fromIntegral (minBound :: Int16))         roundtrip @Word8 "minBound(Word8)" "Word8" "tinyint" minBound)   quickCheckRoundtrip @Day "Day" "date"-  quickCheckRoundtrip @Datetime2 "LocalTime" "datetime2"-  quickCheckRoundtrip @Smalldatetime "LocalTime" "datetime2"+  quickCheckRoundtrip @Datetime2 "Datetime2" "datetime2"+  quickCheckRoundtrip @Smalldatetime "Smalldatetime" "smalldatetime"   quickCheckRoundtrip @TestDateTime "TestDateTime" "datetime"   quickCheckOneway @TimeOfDay "TimeOfDay" "time"   quickCheckRoundtrip @TestTimeOfDay "TimeOfDay" "time"   quickCheckRoundtrip @Float "Float" "real"   quickCheckRoundtrip @Double "Double" "float"   quickCheckRoundtrip @Decimal "Double" ("decimal(" <> show decimalPrecision <> ", " <> show decimalScale <> ")")+  quickCheckRoundtrip @Decimal "Double" ("numeric(" <> show decimalPrecision <> ", " <> show decimalScale <> ")")   quickCheckRoundtrip @Double "Float" "float"   quickCheckRoundtrip @Word8 "Word8" "tinyint"   quickCheckRoundtrip @Int "Int" "bigint"@@ -634,4 +635,12 @@              (secondsToDiffTime seconds + (fromRational (fractional % 1000))))  deriving instance Arbitrary Datetime2-deriving instance Arbitrary Smalldatetime+instance Arbitrary Smalldatetime where+  arbitrary = do+    minutes <- choose (0, 1440)+    day <-+      do offset <- choose (0, 179)+         pure (addDays offset (fromGregorian 1900 01 01))+    pure+      (Smalldatetime+         (LocalTime day (timeToTimeOfDay (secondsToDiffTime (minutes * 60)))))