mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-01 22:02:07 +03:00
Simplify.
This commit is contained in:
parent
4c96f3f5c8
commit
528dbc8f59
@ -26,8 +26,9 @@ module Database.HDBC.Query.TH (
|
||||
inlineVerifiedQuery
|
||||
) where
|
||||
|
||||
import Data.Maybe (listToMaybe, isJust, catMaybes)
|
||||
import Data.Maybe (listToMaybe, fromMaybe)
|
||||
import qualified Data.Map as Map
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad (when)
|
||||
|
||||
import Database.HDBC (IConnection, SqlValue, prepare)
|
||||
@ -112,13 +113,8 @@ defineTableFromDB connect drv scm tbl derives = do
|
||||
$ "defineTableFromDB: fail to find index of pkey - " ++ k ++ ". Something wrong!!"
|
||||
return found
|
||||
|
||||
primaryIxs <- case primCols of
|
||||
_:_ -> do
|
||||
founds <- mapM lookup' primCols
|
||||
if all isJust founds
|
||||
then return $ catMaybes founds
|
||||
else return []
|
||||
[] -> return []
|
||||
primaryIxs <- fromMaybe [] . sequence <$> mapM lookup' primCols
|
||||
|
||||
return (cols, notNullIdxs, primaryIxs) )
|
||||
|
||||
(cols, notNullIdxs, primaryIxs) <- runIO getDBinfo
|
||||
|
Loading…
Reference in New Issue
Block a user