clean up examples.

This commit is contained in:
Kazu Yamamoto 2014-12-12 12:18:58 +09:00
parent 4e03f0066f
commit 50b766f468
2 changed files with 21 additions and 36 deletions

View File

@ -11,9 +11,10 @@ category: Database
build-type: Simple
cabal-version: >=1.10
library
executable examples
hs-source-dirs: src
exposed-modules: Account
main-is: Examples.hs
other-modules: Account
Branch
Business
Customer
@ -26,29 +27,16 @@ library
ProductType
Transaction
build-depends: base <5
, time
, template-haskell
, HDBC
, HDBC-session
, HDBC-sqlite3
, names-th
, sql-words
, HDBC-session
, persistable-record
, relational-query
, relational-query-HDBC
, relational-schemas
, relational-query-HDBC
default-language: Haskell2010
executable query
hs-source-dirs: mains
main-is: Query.hs
build-depends: base <5
, HDBC
, HDBC-sqlite3
, HDBC-session
, persistable-record
, relational-query
, relational-query-HDBC
, relational-record-examples
, sql-words
, template-haskell
, time
default-language: Haskell2010

View File

@ -165,9 +165,9 @@ group1 = aggregateRelation $ do
-- run and print sql
--
runAndPrint :: (Show a, IConnection conn, FromSql SqlValue a, ToSql SqlValue p)
=> conn -> Relation p a -> p -> IO ()
runAndPrint conn rel param = do
run :: (Show a, IConnection conn, FromSql SqlValue a, ToSql SqlValue p)
=> conn -> p -> Relation p a -> IO ()
run conn param rel = do
putStrLn $ "SQL: " ++ show rel
records <- runQuery conn (relationalQuery rel) param
mapM_ print records
@ -175,16 +175,13 @@ runAndPrint conn rel param = do
main :: IO ()
main = handleSqlError' $ withConnectionIO connect $ \conn -> do
let run :: (Show a, FromSql SqlValue a, ToSql SqlValue p) => Relation p a -> p -> IO ()
run = runAndPrint conn
run allAccount ()
run account1 ()
run account1' ()
run join1 ()
run join1' ()
run selfJoin1 ()
run selfJoin1' ()
run union1 ()
run union1' ()
run group1 ()
run conn () allAccount
run conn () account1
run conn () account1'
run conn () join1
run conn () join1'
run conn () selfJoin1
run conn () selfJoin1'
run conn () union1
run conn () union1'
run conn () group1