hpqtypes 1.2.5 → 1.3.0
raw patch · 4 files changed
+11/−12 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Database.PostgreSQL.PQTypes.Composite: fromComposite :: CompositeToSQL t => t -> IO (CompositeRow t)
+ Database.PostgreSQL.PQTypes.Composite: fromComposite :: CompositeToSQL t => t -> CompositeRow t
- Database.PostgreSQL.PQTypes.Composite: toComposite :: CompositeFromSQL t => CompositeRow t -> IO t
+ Database.PostgreSQL.PQTypes.Composite: toComposite :: CompositeFromSQL t => CompositeRow t -> t
Files
- hpqtypes.cabal +1/−1
- src/Database/PostgreSQL/PQTypes/Array.hs +2/−2
- src/Database/PostgreSQL/PQTypes/Composite.hs +4/−5
- test/Main.hs +4/−4
hpqtypes.cabal view
@@ -1,5 +1,5 @@ name: hpqtypes-version: 1.2.5+version: 1.3.0 synopsis: Haskell bindings to libpqtypes description: Efficient and easy-to-use bindings to (slightly modified)
src/Database/PostgreSQL/PQTypes/Array.hs view
@@ -88,7 +88,7 @@ fromSQL (Just arr) = getArray1 CompositeArray1 arr ffmt getItem where ffmt = pqFormat (undefined::CompositeRow t)- getItem res err i (_::Ptr CInt) fmt = fromRow res err i fmt >>= toComposite+ getItem res err i (_::Ptr CInt) fmt = toComposite <$> fromRow res err i fmt instance CompositeToSQL t => ToSQL (CompositeArray1 t) where type PQDest (CompositeArray1 t) = PGarray@@ -198,7 +198,7 @@ fromSQL (Just arr) = getArray2 CompositeArray2 arr ffmt getItem where ffmt = pqFormat (undefined::CompositeRow t)- getItem res err i (_::Ptr CInt) fmt = fromRow res err i fmt >>= toComposite+ getItem res err i (_::Ptr CInt) fmt = toComposite <$> fromRow res err i fmt instance CompositeToSQL t => ToSQL (CompositeArray2 t) where type PQDest (CompositeArray2 t) = PGarray
src/Database/PostgreSQL/PQTypes/Composite.hs view
@@ -42,12 +42,12 @@ -- | Class which represents \"from SQL to composite\" transformation. class (PQFormat t, FromRow (CompositeRow t)) => CompositeFromSQL t where -- | Convert composite row to destination type.- toComposite :: CompositeRow t -> IO t+ toComposite :: CompositeRow t -> t -- | Class which represents \"from composite to SQL\" transformation. class (PQFormat t, ToRow (CompositeRow t)) => CompositeToSQL t where -- | Convert composite type to its intermediate representation.- fromComposite :: t -> IO (CompositeRow t)+ fromComposite :: t -> CompositeRow t instance PQFormat t => PQFormat (Composite t) where pqFormat _ = pqFormat (undefined::t)@@ -56,11 +56,10 @@ type PQBase (Composite t) = Ptr PGresult fromSQL Nothing = unexpectedNULL fromSQL (Just res) = Composite- <$> E.finally (fromRow' res 0 >>= toComposite) (c_PQclear res)+ <$> E.finally (toComposite <$> fromRow' res 0) (c_PQclear res) instance CompositeToSQL t => ToSQL (Composite t) where type PQDest (Composite t) = PGparam toSQL (Composite comp) allocParam conv = allocParam $ \param -> do- row <- fromComposite comp- toRow' row allocParam param+ toRow' (fromComposite comp) allocParam param conv param
test/Main.hs view
@@ -180,9 +180,9 @@ instance PQFormat Simple where pqFormat _ = "%simple_" instance CompositeFromSQL Simple where- toComposite (a, b) = return $ Simple a b+ toComposite (a, b) = Simple a b instance CompositeToSQL Simple where- fromComposite (Simple a b) = return (a, b)+ fromComposite (Simple a b) = (a, b) instance Arbitrary Simple where arbitrary = Simple <$> arbitrary <*> arbitrary@@ -195,9 +195,9 @@ instance PQFormat Nested where pqFormat _ = "%nested_" instance CompositeFromSQL Nested where- toComposite (a, b) = return $ Nested a (unComposite <$> b)+ toComposite (a, b) = Nested a (unComposite <$> b) instance CompositeToSQL Nested where- fromComposite (Nested a b) = return (a, Composite <$> b)+ fromComposite (Nested a b) = (a, Composite <$> b) instance Arbitrary Nested where arbitrary = Nested <$> arbitrary <*> arbitrary