git.iko.soy/typeable/postgresql-simple
on master help sign in
Documentation fixes
93c556fLeon P Smith
src/Database/PostgreSQL/Simple.hs+7−5
@@ -696,7 +696,7 @@ fmtError msg q xs = throw FormatError {
696--
696--
697-- The obvious approach would appear to be something like this:
697-- The obvious approach would appear to be something like this:
698--
698--
699−-- > instance (Param a) => QueryParam a where
699+-- > instance (ToField a) => ToRow a where
700-- > ...
700-- > ...
701--
701--
702-- Unfortunately, this wreaks havoc with type inference, so we take a
702-- Unfortunately, this wreaks havoc with type inference, so we take a
@@ -775,9 +775,10 @@ fmtError msg q xs = throw FormatError {
775
775
776-- $returning
776-- $returning
777--
777--
778−-- The 'returning' function is similar to 'executeMany' but is
778+-- PostgreSQL supports returning values from data manipulation statements
779−-- intended for use with multi-tuple @INSERT@ or @UPDATE@ statements
779+-- such as @INSERT@ and @UPDATE@. You can use these statements by
780−-- that make use of @RETURNING@.
780+-- using 'query' instead of 'execute'. For multi-tuple inserts,
781+-- use 'returning' instead of 'executeMany'.
781--
782--
782-- For example, were there an auto-incrementing @id@ column and
783-- For example, were there an auto-incrementing @id@ column and
783-- timestamp column @t@ that defaulted to the present time for the
784-- timestamp column @t@ that defaulted to the present time for the
@@ -785,7 +786,8 @@ fmtError msg q xs = throw FormatError {
785-- sales records and also return their new @id@s and timestamps.
786-- sales records and also return their new @id@s and timestamps.
786--
787--
787-- > let q = "insert into sales (amount, label) values (?,?) returning id, t"
788-- > let q = "insert into sales (amount, label) values (?,?) returning id, t"
789+-- > xs :: [(Int, UTCTime)] <- query conn q (15,"Sawdust")
788−-- > xs :: [(Int, UTCTime)] <- returning conn q [(20,"Chips"),(300,"Wood")]
790+-- > ys :: [(Int, UTCTime)] <- returning conn q [(20,"Chips"),(300,"Wood")]
789
791
790-- $result
792-- $result
791--
793--