packages feed

postgresql-simple-sop 0.1.0.6 → 0.1.0.7

raw patch · 2 files changed

+12/−2 lines, 2 files

Files

postgresql-simple-sop.cabal view
@@ -1,5 +1,5 @@ name:                postgresql-simple-sop-version:             0.1.0.6+version:             0.1.0.7 synopsis:            Generic functions for postgresql-simple homepage:            https://github.com/openbrainsrc/postgresql-simple-sop license:             MIT
src/Database/PostgreSQL/Simple/SOP.hs view
@@ -24,7 +24,7 @@  -} -module Database.PostgreSQL.Simple.SOP (gfromRow, gtoRow, gselectFrom, ginsertInto, HasFieldNames, fieldNames) where+module Database.PostgreSQL.Simple.SOP (gfromRow, gtoRow, gselectFrom, ginsertInto, ginsertManyInto, HasFieldNames, fieldNames) where  import Generics.SOP import Control.Applicative@@ -103,4 +103,14 @@                      ") VALUES (" <>                      (fromString $ intercalate "," $ map (const "?") fnms) <> ")")                val+  return ()++ginsertManyInto :: forall r. (ToRow r, Generic r, HasFieldNames r) => Connection -> Query -> [r] -> IO ()+ginsertManyInto conn tbl vals = do+  let fnms = fieldNames $ (Proxy :: Proxy r)+  _ <- executeMany conn ("INSERT INTO " <> tbl <> " (" <>+                     (fromString $ intercalate "," fnms ) <>+                     ") VALUES (" <>+                     (fromString $ intercalate "," $ map (const "?") fnms) <> ")")+               vals   return ()