HDBC 2.4.0.0 → 2.4.0.1
raw patch · 6 files changed
+60/−17 lines, 6 filesdep ~timenew-uploader
Dependency ranges changed: time
Files
- CHANGELOG.md +8/−0
- Database/HDBC.hs +2/−2
- Database/HDBC/Locale.hs +6/−0
- Database/HDBC/SqlValue.hs +25/−8
- Database/HDBC/Utils.hs +3/−3
- HDBC.cabal +16/−4
+ CHANGELOG.md view
@@ -0,0 +1,8 @@+# Changelog++#### 2.4.0.1++* Compatibility with time 1.5.+* Minor documentation fixes.++
Database/HDBC.hs view
@@ -128,9 +128,9 @@ * Support for querying database server properties * Add-on package (hdbc-missingh) to integrate with MissingH,- providing a database backend for AnyDBM.+ providing a database backend for AnyDBM - * Support for querying metadata such as column names.+ * Support for querying metadata such as column names * Support for querying additional metadata (column types, etc.) -}
Database/HDBC/Locale.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Database.HDBC.Locale ( defaultTimeLocale,@@ -5,7 +6,12 @@ ) where++#ifdef MIN_TIME_15+import Data.Time.Format (defaultTimeLocale)+#else import System.Locale (defaultTimeLocale)+#endif -- | As the semantic of System.Locale.iso8601DateFormat has changed with -- old-locale-1.0.0.2 in a non-compatible way, we now define our own
Database/HDBC/SqlValue.hs view
@@ -17,7 +17,16 @@ import Data.Word import Data.Int import qualified System.Time as ST-import Data.Time+import Data.Time ( Day (ModifiedJulianDay), DiffTime, LocalTime, NominalDiffTime, ParseTime+ , TimeOfDay, TimeZone, UTCTime, ZonedTime, formatTime, localDay, localTimeOfDay+ , timeOfDayToTime, timeToTimeOfDay, toModifiedJulianDay, utc+ , utcToZonedTime, zonedTimeToLocalTime, zonedTimeToUTC, zonedTimeZone+#if MIN_TIME_15+ , parseTimeM+#else+ , parseTime+#endif+ ) import Data.Time.Clock.POSIX import Database.HDBC.Locale (defaultTimeLocale, iso8601DateFormat) import Data.Ratio@@ -61,7 +70,7 @@ posixToSql :: POSIXTime -> SqlValue posixToSql x = SqlPOSIXTime x -{- | 'SqlValue' is he main type for expressing Haskell values to SQL databases.+{- | 'SqlValue' is the main type for expressing Haskell values to SQL databases. /INTRODUCTION TO SQLVALUE/ @@ -169,7 +178,7 @@ * Both represent the same type and the encapsulated values are considered equal by applying (==) to them - * The values of each, when converted to a string, are equal.+ * The values of each, when converted to a string, are equal /STRING VERSIONS OF TIMES/ @@ -200,17 +209,17 @@ | SqlBool Bool | SqlDouble Double | SqlRational Rational- | SqlLocalDate Day -- ^ Local YYYY-MM-DD (no timezone)- | SqlLocalTimeOfDay TimeOfDay -- ^ Local HH:MM:SS (no timezone)+ | SqlLocalDate Day -- ^ Local YYYY-MM-DD (no timezone).+ | SqlLocalTimeOfDay TimeOfDay -- ^ Local HH:MM:SS (no timezone). | SqlZonedLocalTimeOfDay TimeOfDay TimeZone -- ^ Local HH:MM:SS -HHMM. Converts to and from (TimeOfDay, TimeZone).- | SqlLocalTime LocalTime -- ^ Local YYYY-MM-DD HH:MM:SS (no timezone)+ | SqlLocalTime LocalTime -- ^ Local YYYY-MM-DD HH:MM:SS (no timezone). | SqlZonedTime ZonedTime -- ^ Local YYYY-MM-DD HH:MM:SS -HHMM. Considered equal if both convert to the same UTC time.- | SqlUTCTime UTCTime -- ^ UTC YYYY-MM-DD HH:MM:SS+ | SqlUTCTime UTCTime -- ^ UTC YYYY-MM-DD HH:MM:SS. | SqlDiffTime NominalDiffTime -- ^ Calendar diff between seconds. Rendered as Integer when converted to String, but greater precision may be preserved for other types or to underlying database. | SqlPOSIXTime POSIXTime -- ^ Time as seconds since midnight Jan 1 1970 UTC. Integer rendering as for 'SqlDiffTime'. | SqlEpochTime Integer -- ^ DEPRECATED Representation of ClockTime or CalendarTime. Use SqlPOSIXTime instead. | SqlTimeDiff Integer -- ^ DEPRECATED Representation of TimeDiff. Use SqlDiffTime instead.- | SqlNull -- ^ NULL in SQL or Nothing in Haskell+ | SqlNull -- ^ NULL in SQL or Nothing in Haskell. deriving (Show, Typeable) instance Eq SqlValue where@@ -661,7 +670,11 @@ instance Convertible SqlValue (TimeOfDay, TimeZone) where safeConvert (SqlString x) = do tod <- parseTime' "%T%Q %z" x+#if MIN_TIME_15+ tz <- case parseTimeM True defaultTimeLocale "%T%Q %z" x of+#else tz <- case parseTime defaultTimeLocale "%T%Q %z" x of+#endif Nothing -> convError "Couldn't extract timezone in" (SqlString x) Just y -> Right y return (tod, tz)@@ -935,7 +948,11 @@ #else parseTime' :: (Typeable t, Convertible SqlValue t, ParseTime t) => String -> String -> ConvertResult t parseTime' fmtstr inpstr = +#if MIN_TIME_15+ case parseTimeM True defaultTimeLocale fmtstr inpstr of+#else case parseTime defaultTimeLocale fmtstr inpstr of+#endif Nothing -> convError ("Cannot parse using default format string " ++ show fmtstr) (SqlString inpstr) Just x -> Right x
Database/HDBC/Utils.hs view
@@ -215,7 +215,7 @@ Just r -> do names <- getColumnNames sth return $ Just $ zip names r -{- | Strict version of 'fetchRowAL' -}+{- | Strict version of 'fetchRowAL'. -} fetchRowAL' :: Statement -> IO (Maybe [(String, SqlValue)]) fetchRowAL' sth = do res <- fetchRowAL sth@@ -233,7 +233,7 @@ Nothing -> return Nothing Just x -> return $ Just $ Map.fromList x -{- | Strict version of 'fetchRowMap' -}+{- | Strict version of 'fetchRowMap'. -} fetchRowMap' :: Statement -> IO (Maybe (Map.Map String SqlValue)) fetchRowMap' sth = do res <- fetchRowMap sth@@ -272,7 +272,7 @@ return res {- | A quick way to do a query. Similar to preparing, executing, and-then calling 'fetchAllRows' on a statement. See also 'quickQuery'' -}+then calling 'fetchAllRows' on a statement. See also 'quickQuery''. -} quickQuery :: IConnection conn => conn -> String -> [SqlValue] -> IO [[SqlValue]] quickQuery conn qrystr args = do sth <- prepare conn qrystr
HDBC.cabal view
@@ -1,12 +1,12 @@ Name: HDBC-Version: 2.4.0.0+Version: 2.4.0.1 License: BSD3 Maintainer: Nicolas Wu <nicolas.wu@gmail.com> Author: John Goerzen, Nicolas Wu homepage: https://github.com/hdbc/hdbc Copyright: Copyright (c) 2005-2011 John Goerzen license-file: LICENSE-extra-source-files: LICENSE, Makefile, README.md+extra-source-files: LICENSE, Makefile, README.md, CHANGELOG.md Category: Database synopsis: Haskell Database Connectivity Description: HDBC provides an abstraction layer between Haskell programs and SQL@@ -27,10 +27,18 @@ flag buildtests description: Build the executable to run unit tests default: False+flag minTime15+ description: Use time 1.5 or higher.+ default: True library if flag(splitBase)- Build-Depends: base>=3 && <5, old-time, time>=1.1.3 && <=1.5, bytestring, containers, old-locale+ Build-Depends: base>=3 && <5, old-time, bytestring, containers+ if flag(minTime15)+ Build-Depends: time >= 1.5 && < 1.6+ CPP-Options: -DMIN_TIME_15+ else+ Build-Depends: time < 1.5, old-locale else Build-Depends: base<3 Build-Depends: mtl, convertible >= 1.1.0.0, text, utf8-string@@ -56,7 +64,11 @@ Build-Depends: HUnit, QuickCheck (>= 2.0), testpack (>= 2.0) if flag(splitBase)- Build-Depends: base>=3 && <5, old-time, time>=1.1.3 && <=1.5, bytestring, containers, old-locale+ Build-Depends: base>=3 && <5, old-time, bytestring, containers+ if flag(minTime15)+ Build-Depends: time >= 1.5 && < 1.6+ else+ Build-Depends: time < 1.5, old-locale else Build-Depends: base<3 Build-Depends: mtl, convertible >= 1.1.0.0, utf8-string, text