add generalized table initializer.

This commit is contained in:
Kei Hibino 2016-12-18 14:35:43 +09:00
parent ec3125128a
commit a718ab2925
2 changed files with 19 additions and 0 deletions

View File

@ -18,6 +18,7 @@ cabal-version: >=1.10
library
exposed-modules:
Test.Relational.QuickCheck.Model
Test.Relational.QuickCheck.Transaction
Test.Relational.QuickCheck.Arbitrary
-- other-modules:
other-extensions: TemplateHaskell, MultiParamTypeClasses, FlexibleInstances
@ -25,6 +26,7 @@ library
, QuickCheck >=2
, HDBC
, HDBC-session
, persistable-record
, relational-query
, relational-query-HDBC
hs-source-dirs: src

View File

@ -0,0 +1,17 @@
{-# LANGUAGE FlexibleContexts #-}
module Test.Relational.QuickCheck.Transaction (
initializeTable,
) where
import Database.HDBC (IConnection, SqlValue)
import Database.Record (ToSql)
import Database.Relational.Query
import Database.HDBC.Record (runInsert)
initializeTable :: (IConnection conn, TableDerivable a, ToSql SqlValue a)
=> conn
-> [a]
-> IO ()
initializeTable conn xs = mapM_ (runInsert conn $ derivedInsert id') xs