postgresql-simple 0.2.0.1 → 0.2.1.0
raw patch · 4 files changed
+14/−7 lines, 4 filesdep −old-localePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: old-locale
API changes (from Hackage documentation)
+ Database.PostgreSQL.Simple.FromField: type FieldParser a = Field -> Maybe ByteString -> Ok a
+ Database.PostgreSQL.Simple.FromRow: fieldWith :: FieldParser a -> RowParser a
- Database.PostgreSQL.Simple.FromField: fromField :: FromField a => Field -> Maybe ByteString -> Ok a
+ Database.PostgreSQL.Simple.FromField: fromField :: FromField a => FieldParser a
Files
- CONTRIBUTORS +1/−0
- postgresql-simple.cabal +2/−3
- src/Database/PostgreSQL/Simple/FromField.hs +4/−1
- src/Database/PostgreSQL/Simple/FromRow.hs +7/−3
CONTRIBUTORS view
@@ -4,3 +4,4 @@ Ozgun Ataman <ozataman@gmail.com> Joey Adams <joeyadams3.14159@gmail.com> Rekado <rekado@elephly.net>+Leonid Onokhov <sopvop@gmail.com>
postgresql-simple.cabal view
@@ -1,5 +1,5 @@ Name: postgresql-simple-Version: 0.2.0.1+Version: 0.2.1.0 Synopsis: Mid-Level PostgreSQL client library Description: Mid-Level PostgreSQL client library, forked from mysql-simple.@@ -48,7 +48,6 @@ bytestring >= 0.9, containers, postgresql-libpq >= 0.6.2,- old-locale, template-haskell, text >= 0.11.1, time,@@ -67,7 +66,7 @@ source-repository this type: git location: http://github.com/lpsmith/postgresql-simple- tag: v0.2+ tag: v0.2.1.0 test-suite test type: exitcode-stdio-1.0
src/Database/PostgreSQL/Simple/FromField.hs view
@@ -27,6 +27,7 @@ module Database.PostgreSQL.Simple.FromField ( FromField(..)+ , FieldParser , ResultError(..) , returnError @@ -95,9 +96,11 @@ left :: Exception a => a -> Ok b left = Errors . (:[]) . SomeException +type FieldParser a = Field -> Maybe ByteString -> Ok a+ -- | A type that may be converted from a SQL type. class FromField a where- fromField :: Field -> Maybe ByteString -> Ok a+ fromField :: FieldParser a -- ^ Convert a SQL value to a Haskell value. -- -- Returns a list of exceptions if the conversion fails. In the case of
src/Database/PostgreSQL/Simple/FromRow.hs view
@@ -20,6 +20,7 @@ ( FromRow(..) , RowParser , field+ , fieldWith , numFieldsRemaining ) where @@ -64,8 +65,8 @@ class FromRow a where fromRow :: RowParser a -field :: FromField a => RowParser a-field = RP $ do+fieldWith :: FieldParser a -> RowParser a+fieldWith fieldP = RP $ do let unCol (PQ.Col x) = fromIntegral x :: Int Row{..} <- ask column <- lift get@@ -87,7 +88,10 @@ let typename = typenames ! unCol column result = rowresult field = Field{..}- lift (lift (fromField field (getvalue result row column)))+ lift (lift (fieldP field (getvalue result row column)))++field :: FromField a => RowParser a+field = fieldWith fromField ellipsis :: ByteString -> ByteString ellipsis bs