packages feed

postgresql-simple 0.4.3.0 → 0.4.4.0

raw patch · 6 files changed

+50/−14 lines, 6 files

Files

postgresql-simple.cabal view
@@ -1,5 +1,5 @@ Name:                postgresql-simple-Version:             0.4.3.0+Version:             0.4.4.0 Synopsis:            Mid-Level PostgreSQL client library Description:     Mid-Level PostgreSQL client library, forked from mysql-simple.@@ -81,7 +81,7 @@ source-repository this   type:     git   location: http://github.com/lpsmith/postgresql-simple-  tag:      v0.4.3.0+  tag:      v0.4.4.0  test-suite test   type:           exitcode-stdio-1.0
src/Database/PostgreSQL/Simple.hs view
@@ -697,10 +697,11 @@ -- > -- > import Database.PostgreSQL.Simple -- >--- > hello :: IO [Only Int]+-- > hello :: IO Int -- > hello = do -- >   conn <- connectPostgreSQL ""--- >   query_ conn "select 2 + 2"+-- >   [Only i] <- query_ conn "select 2 + 2"+-- >   return i -- -- A 'Query' value does not represent the actual query that will be -- executed, but is a template for constructing the final query.@@ -761,11 +762,26 @@ -- The same kind of problem can arise with string literals if you have -- the @OverloadedStrings@ language extension enabled.  Again, just -- use an explicit type signature if this happens.+--+-- Finally, remember that the compiler must be able to infer the type+-- of a query's /results/ as well as its parameters.  We might like+-- the following example to work:+--+-- > print =<< query_ conn "select 2 + 2"+--+-- Unfortunately, while a quick glance tells us that the result type+-- should be a single row containing a single numeric column, the+-- compiler has no way to infer what the types are.  We can easily fix+-- this by providing an explicit type annotation:+--+-- > xs <- query_ conn "select 2 + 2"+-- > print (xs :: [Only Int])  -- $only_param -- -- Haskell lacks a single-element tuple type, so if you have just one--- value you want substituted into a query, what should you do?+-- value you want substituted into a query or a single-column result,+-- what should you do? -- -- The obvious approach would appear to be something like this: --@@ -780,6 +796,9 @@ -- -- > execute conn "insert into users (first_name) values (?)" -- >              ["Nuala"]+--+-- A row of /n/ query results is represented using an /n/-tuple, so+-- you should use 'Only' to represent a single-column result.  -- $in --
src/Database/PostgreSQL/Simple/BuiltinTypes.hs view
@@ -74,6 +74,7 @@    | Void    | UUID    | JSON+   | JSONB      deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable)  builtin2oid :: BuiltinType -> PQ.Oid@@ -125,6 +126,7 @@   Void        -> 2278   UUID        -> 2950   JSON        ->  114+  JSONB       -> 3802  oid2builtin :: PQ.Oid -> Maybe BuiltinType oid2builtin (PQ.Oid x) = case x of@@ -175,6 +177,7 @@   2278 -> Just Void   2950 -> Just UUID   114  -> Just JSON+  3802 -> Just JSONB   _    -> Nothing  builtin2typname :: BuiltinType -> ByteString@@ -226,6 +229,7 @@   Void        -> void   UUID        -> uuid   JSON        -> json+  JSONB       -> jsonb  oid2typname :: PQ.Oid -> Maybe ByteString oid2typname (PQ.Oid x) = case x of@@ -276,6 +280,7 @@   2278 -> Just void   2950 -> Just uuid   114  -> Just json+  3802 -> Just jsonb   _ -> Nothing  bool :: ByteString@@ -418,3 +423,6 @@  json :: ByteString json = "json"++jsonb :: ByteString+jsonb = "jsonb"
src/Database/PostgreSQL/Simple/FromField.hs view
@@ -27,11 +27,11 @@ conversion routine,  which sacrifices some accuracy for speed.   If you need accuracy,  consider first converting data to a 'Scientific' or 'Rational' type,  and then converting to a floating-point type.   If you are defining-your own 'Database.PostgreSQL.Simple.FromRow.FromRow' instances,  this can be -acheived simply by -@'fromRational' '<$>' 'Database.PostgreSQL.Simple.FromRow.field'@,  although +your own 'Database.PostgreSQL.Simple.FromRow.FromRow' instances,  this can be+acheived simply by+@'fromRational' '<$>' 'Database.PostgreSQL.Simple.FromRow.field'@,  although this idiom is additionally compatible with PostgreSQL's @numeric@ type.-If this is unacceptable,  you may find +If this is unacceptable,  you may find 'Database.PostgreSQL.Simple.FromRow.fieldWith' useful.  Because 'FromField' is a typeclass,  one may provide conversions to@@ -104,12 +104,11 @@  #include "MachDeps.h" -import           Control.Applicative-                   ( Applicative, (<|>), (<$>), pure )+import           Control.Applicative ( (<|>), (<$>), pure ) import           Control.Concurrent.MVar (MVar, newMVar) import           Control.Exception (Exception) import qualified Data.Aeson as JSON-import           Data.Attoparsec.Char8 hiding (Result)+import           Data.Attoparsec.ByteString.Char8 hiding (Result) import           Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as B import           Data.Int (Int16, Int32, Int64)@@ -492,7 +491,7 @@ -- | json instance FromField JSON.Value where     fromField f mbs =-      if typeOid f /= $(inlineTypoid TI.json)+      if typeOid f /= $(inlineTypoid TI.json) && typeOid f /= $(inlineTypoid TI.jsonb)       then returnError Incompatible f ""       else case mbs of              Nothing -> returnError UnexpectedNull f ""
src/Database/PostgreSQL/Simple/ToRow.hs view
@@ -26,7 +26,7 @@ -- | A collection type that can be turned into a list of rendering -- 'Action's. ----- Instances should use the 'render' method of the 'Param' class+-- Instances should use the 'toField' method of the 'ToField' class -- to perform conversion of each element of the collection. class ToRow a where     toRow :: a -> [Action]
src/Database/PostgreSQL/Simple/TypeInfo/Static.hs view
@@ -65,6 +65,7 @@      , void      , uuid      , json+     , jsonb      ) where  import Database.PostgreSQL.LibPQ (Oid(..))@@ -119,6 +120,7 @@     2278 -> Just void     2950 -> Just uuid     114  -> Just json+    3802 -> Just jsonb     _ -> Nothing  bool :: TypeInfo@@ -495,4 +497,12 @@     typcategory = 'U',     typdelim    = ',',     typname     = "json"+  }++jsonb :: TypeInfo+jsonb =  Basic {+    typoid      = Oid 3802,+    typcategory = 'U',+    typdelim    = ',',+    typname     = "jsonb"   }