sqlite-simple 0.4.0.0 → 0.4.1.0
raw patch · 5 files changed
+22/−5 lines, 5 files
Files
- Database/SQLite/Simple.hs +1/−1
- Database/SQLite/Simple/FromField.hs +10/−2
- Database/SQLite/Simple/Internal.hs +8/−1
- sqlite-simple.cabal +1/−1
- test/Main.hs +2/−0
Database/SQLite/Simple.hs view
@@ -38,7 +38,7 @@ -- ** Type conversions -- $types Query(..)- , Connection+ , Connection(..) , ToRow(..) , FromRow(..) , Only(..)
Database/SQLite/Simple/FromField.hs view
@@ -39,10 +39,12 @@ import Control.Exception (SomeException(..), Exception) import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as B+import qualified Data.ByteString.Lazy as LB import Data.Int (Int16, Int32, Int64) import Data.Time (UTCTime, Day) import Data.Time.Format (parseTime) import qualified Data.Text as T+import qualified Data.Text.Lazy as LT import Data.Typeable (Typeable, typeOf) import System.Locale (defaultTimeLocale)@@ -139,14 +141,20 @@ fromField (Field (SQLText txt) _) = Ok txt fromField f = returnError ConversionFailed f "need a text" +instance FromField LT.Text where+ fromField (Field (SQLText txt) _) = Ok . LT.fromStrict $ txt+ fromField f = returnError ConversionFailed f "need a text"+ instance FromField [Char] where fromField (Field (SQLText t) _) = Ok $ T.unpack t fromField f = returnError ConversionFailed f "expecting SQLText column type" --- TODO ToRow has both T and LB variants of ByteString, check what's--- really needed here instance FromField ByteString where fromField (Field (SQLBlob blb) _) = Ok blb+ fromField f = returnError ConversionFailed f "expecting SQLBlob column type"++instance FromField LB.ByteString where+ fromField (Field (SQLBlob blb) _) = Ok . LB.fromChunks $ [blb] fromField f = returnError ConversionFailed f "expecting SQLBlob column type" instance FromField UTCTime where
Database/SQLite/Simple/Internal.hs view
@@ -32,7 +32,14 @@ import qualified Database.SQLite3 as Base -- | Connection to an open database.-data Connection = Connection Base.Database+--+-- You can use 'connectionHandle' to gain access to the underlying+-- <http://hackage.haskell.org/package/direct-sqlite> connection.+-- This may be useful if you need to access some direct-sqlite+-- functionality that's not exposed in the sqlite-simple API. This+-- should be a safe thing to do although mixing both APIs is+-- discouraged.+newtype Connection = Connection { connectionHandle :: Base.Database } -- | A Field represents metadata about a particular field
sqlite-simple.cabal view
@@ -1,5 +1,5 @@ Name: sqlite-simple-Version: 0.4.0.0+Version: 0.4.1.0 Synopsis: Mid-Level SQLite client library Description: Mid-level SQLite client library, based on postgresql-simple.
test/Main.hs view
@@ -14,6 +14,7 @@ import Fold import Statement import Debug+import DirectSqlite tests :: [TestEnv -> Test] tests =@@ -38,6 +39,7 @@ , TestLabel "Statement" . testDoubleBind , TestLabel "Statement" . testPreparedStatements , TestLabel "Debug" . testDebugTracing+ , TestLabel "Direct" . testDirectSqlite ] -- | Action for connecting to the database that will be used for testing.