This commit is contained in:
Kei Hibino 2013-03-26 21:38:42 +09:00
parent 8f8c59b064
commit 50ab897862

View File

@ -40,7 +40,7 @@ module Database.HDBC.TH (
defineSqls, defineSqlsDefault, defineSqls, defineSqlsDefault,
defineTableDefault, defineWithTableDefault,
defineWithPrimaryKeyDefault, defineWithPrimaryKeyDefault,
defineWithNotNullKeyDefault, defineWithNotNullKeyDefault,
@ -395,12 +395,12 @@ defineSqlsWithPrimaryKeyDefault schema table fields idx =
sel = table `varNameWithPrefix` "select" sel = table `varNameWithPrefix` "select"
upd = table `varNameWithPrefix` "update" upd = table `varNameWithPrefix` "update"
defineTableDefault :: String defineWithTableDefault :: String
-> String -> String
-> [(String, TypeQ)] -> [(String, TypeQ)]
-> [ConName] -> [ConName]
-> Q [Dec] -> Q [Dec]
defineTableDefault schema table fields derives = do defineWithTableDefault schema table fields derives = do
recD <- defineRecordDefault schema table fields derives recD <- defineRecordDefault schema table fields derives
sqlD <- defineSqlsDefault schema table fields sqlD <- defineSqlsDefault schema table fields
return $ recD ++ sqlD return $ recD ++ sqlD
@ -441,7 +441,7 @@ defineTableFromDB connect drv scm tbl derives = do
return (cols, notNullIdxs, mayPrimaryIdx) ) return (cols, notNullIdxs, mayPrimaryIdx) )
(cols, notNullIdxs, mayPrimaryIdx) <- runIO getDBinfo (cols, notNullIdxs, mayPrimaryIdx) <- runIO getDBinfo
tblD <- defineTableDefault scm tbl cols derives tblD <- defineWithTableDefault scm tbl cols derives
primD <- mayDeclare (defineWithPrimaryKeyDefault scm tbl cols) mayPrimaryIdx primD <- mayDeclare (defineWithPrimaryKeyDefault scm tbl cols) mayPrimaryIdx
nnD <- mayDeclare (defineWithNotNullKeyDefault tbl) (listToMaybe notNullIdxs) nnD <- mayDeclare (defineWithNotNullKeyDefault tbl) (listToMaybe notNullIdxs)
return $ tblD ++ primD ++ nnD return $ tblD ++ primD ++ nnD