git.iko.soy/typeable/postgresql-simple
on master help sign in
Fix up some warnings
64f5abaLeon P Smith
src/Database/PostgreSQL/Simple.hs+3−21
@@ -110,7 +110,7 @@ import Blaze.ByteString.Builder.Char8 (fromChar)
110import Control.Applicative ((<$>), pure)
110import Control.Applicative ((<$>), pure)
111import Control.Concurrent.MVar
111import Control.Concurrent.MVar
112import Control.Exception
112import Control.Exception
113− ( Exception, bracket, onException, throw, throwIO, finally )
113+ ( Exception, onException, throw, throwIO, finally )
114import Control.Monad (foldM)
114import Control.Monad (foldM)
115import Data.ByteString (ByteString)
115import Data.ByteString (ByteString)
116import Data.Char(ord)
116import Data.Char(ord)
@@ -121,6 +121,7 @@ import Data.Monoid (mappend, mconcat)
121import Data.Typeable (Typeable)
121import Data.Typeable (Typeable)
122import Database.PostgreSQL.Simple.BuiltinTypes
122import Database.PostgreSQL.Simple.BuiltinTypes
123 ( oid2builtin, builtin2typname )
123 ( oid2builtin, builtin2typname )
124+import Database.PostgreSQL.Simple.Compat ( mask )
124import Database.PostgreSQL.Simple.FromField (ResultError(..))
125import Database.PostgreSQL.Simple.FromField (ResultError(..))
125import Database.PostgreSQL.Simple.FromRow (FromRow(..))
126import Database.PostgreSQL.Simple.FromRow (FromRow(..))
126import Database.PostgreSQL.Simple.Ok
127import Database.PostgreSQL.Simple.Ok
@@ -133,7 +134,6 @@ import qualified Database.PostgreSQL.LibPQ as PQ
133import Text.Regex.PCRE.Light (compile, caseless, match)
134import Text.Regex.PCRE.Light (compile, caseless, match)
134import qualified Data.ByteString.Char8 as B
135import qualified Data.ByteString.Char8 as B
135import qualified Data.Vector as V
136import qualified Data.Vector as V
136−import Control.Exception
137import Control.Monad.Trans.Reader
137import Control.Monad.Trans.Reader
138import Control.Monad.Trans.State.Strict
138import Control.Monad.Trans.State.Strict
139
139
@@ -471,7 +471,7 @@ finishQuery conn q result = do
471 throwIO $ QueryError "query resulted in a command response" q
471 throwIO $ QueryError "query resulted in a command response" q
472 PQ.TuplesOk -> do
472 PQ.TuplesOk -> do
473 ncols <- PQ.nfields result
473 ncols <- PQ.nfields result
474− let unCol (PQ.Col x) = fromIntegral x
474+ let unCol (PQ.Col x) = fromIntegral x :: Int
475 typenames <- V.generateM (unCol ncols)
475 typenames <- V.generateM (unCol ncols)
476 (\(PQ.Col . fromIntegral -> col) -> do
476 (\(PQ.Col . fromIntegral -> col) -> do
477 getTypename conn =<< PQ.ftype result col)
477 getTypename conn =<< PQ.ftype result col)
@@ -500,24 +500,6 @@ ellipsis bs
500 | B.length bs > 15 = B.take 10 bs `B.append` "[...]"
500 | B.length bs > 15 = B.take 10 bs `B.append` "[...]"
501 | otherwise = bs
501 | otherwise = bs
502
502
503−-- | Throw a 'ConversionFailed' exception, indicating a mismatch
504−-- between the number of columns in the 'Field' and row, and the
505−-- number in the collection to be converted to.
506−convertError :: [Field]
507− -- ^ Descriptors of fields to be converted.
508− -> [Maybe ByteString]
509− -- ^ Contents of the row to be converted.
510− -> Int
511− -- ^ Number of columns expected for conversion. For
512− -- instance, if converting to a 3-tuple, the number to
513− -- provide here would be 3.
514− -> Either SomeException a
515−convertError fs vs n = Left . SomeException $ ConversionFailed
516− (show (length fs) ++ " values: " ++ show (zip (map typename fs)
517− (map (fmap ellipsis) vs)))
518− (show n ++ " slots in target type")
519− "mismatch between number of columns to convert and number in target type"
520−
521
503
522-- | Of the four isolation levels defined by the SQL standard,
504-- | Of the four isolation levels defined by the SQL standard,
523-- these are the three levels distinguished by PostgreSQL as of version 9.0.
505-- these are the three levels distinguished by PostgreSQL as of version 9.0.
src/Database/PostgreSQL/Simple/FromField.hs+1−1
@@ -32,7 +32,7 @@ module Database.PostgreSQL.Simple.FromField
32#include "MachDeps.h"
32#include "MachDeps.h"
33
33
34import Control.Applicative (Applicative, (<|>), (<$>), (<*>), (<*), pure)
34import Control.Applicative (Applicative, (<|>), (<$>), (<*>), (<*), pure)
35−import Control.Exception (SomeException(..), Exception, throw)
35+import Control.Exception (SomeException(..), Exception)
36import Data.Attoparsec.Char8 hiding (Result)
36import Data.Attoparsec.Char8 hiding (Result)
37import Data.Bits ((.&.), (.|.), shiftL)
37import Data.Bits ((.&.), (.|.), shiftL)
38import Data.ByteString (ByteString)
38import Data.ByteString (ByteString)
src/Database/PostgreSQL/Simple/FromRow.hs+2−5
@@ -24,11 +24,10 @@ module Database.PostgreSQL.Simple.FromRow
24 ) where
24 ) where
25
25
26import Control.Applicative (Applicative(..), (<$>))
26import Control.Applicative (Applicative(..), (<$>))
27−import Control.Exception (SomeException(..), throw)
27+import Control.Exception (SomeException(..))
28import Control.Monad (replicateM)
28import Control.Monad (replicateM)
29import Data.ByteString (ByteString)
29import Data.ByteString (ByteString)
30import qualified Data.ByteString.Char8 as B
30import qualified Data.ByteString.Char8 as B
31−import Database.PostgreSQL.Simple.Internal
32import Database.PostgreSQL.Simple.Types (Only(..))
31import Database.PostgreSQL.Simple.Types (Only(..))
33import Database.PostgreSQL.Simple.Ok
32import Database.PostgreSQL.Simple.Ok
34import qualified Database.PostgreSQL.LibPQ as PQ
33import qualified Database.PostgreSQL.LibPQ as PQ
@@ -41,14 +40,12 @@ import Control.Monad.Trans.Class
41
40
42import Data.Vector ((!))
41import Data.Vector ((!))
43
42
44−import System.IO.Unsafe ( unsafePerformIO )
45−
46class FromRow a where
43class FromRow a where
47 fromRow :: RowParser a
44 fromRow :: RowParser a
48
45
49field :: FromField a => RowParser a
46field :: FromField a => RowParser a
50field = RP $ do
47field = RP $ do
51− let unCol (PQ.Col x) = fromIntegral x
48+ let unCol (PQ.Col x) = fromIntegral x :: Int
52 Row{..} <- ask
49 Row{..} <- ask
53 column <- lift get
50 column <- lift get
54 lift (put (column + 1))
51 lift (put (column + 1))