packages feed

postgresql-simple-sop 0.1.0.5 → 0.1.0.6

raw patch · 2 files changed

+6/−13 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Database.PostgreSQL.Simple.SOP: ginsertManyInto :: (ToRow r, Generic r, HasFieldNames r) => Connection -> Query -> [r] -> IO ()
+ Database.PostgreSQL.Simple.SOP: instance (HasFieldNames a, HasFieldNames b) => HasFieldNames (a :. b)

Files

postgresql-simple-sop.cabal view
@@ -1,5 +1,5 @@ name:                postgresql-simple-sop-version:             0.1.0.5+version:             0.1.0.6 synopsis:            Generic functions for postgresql-simple homepage:            https://github.com/openbrainsrc/postgresql-simple-sop license:             MIT
src/Database/PostgreSQL/Simple/SOP.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DefaultSignatures, OverloadedStrings, ScopedTypeVariables, DeriveGeneric, FlexibleInstances, ConstraintKinds, DataKinds, GADTs #-}+{-# LANGUAGE DefaultSignatures, OverloadedStrings, ScopedTypeVariables, DeriveGeneric, FlexibleInstances, ConstraintKinds, DataKinds, GADTs, TypeOperators #-}  {- | @@ -24,7 +24,7 @@  -} -module Database.PostgreSQL.Simple.SOP (gfromRow, gtoRow, gselectFrom, ginsertInto, ginsertManyInto, HasFieldNames, fieldNames) where+module Database.PostgreSQL.Simple.SOP (gfromRow, gtoRow, gselectFrom, ginsertInto, HasFieldNames, fieldNames) where  import Generics.SOP import Control.Applicative@@ -71,6 +71,9 @@     ADT     _ _ cs -> fNms cs     Newtype _ _ c -> fNms $ c :* Nil +instance (HasFieldNames a, HasFieldNames b) => HasFieldNames (a:.b) where+  fieldNames proxy =fieldNames (Proxy::Proxy a) ++ fieldNames (Proxy::Proxy b)+ {-|Generic select  @@@ -100,14 +103,4 @@                      ") 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 ()