Better error for mkColumn

This commit is contained in:
Adam C. Baker
2014-10-09 14:11:21 -07:00
parent 5dd3f9c79a
commit ea17642f08
+2 -2
View File
@@ -1,4 +1,3 @@
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module PgStructure where module PgStructure where
@@ -151,7 +150,6 @@ columns s t conn = do
return cols return cols
where where
--TODO: handle failed pattern match with an appropriate exception
mkColumn [schema, table, name, pos, nullable, colT, updatable, maxlen, precision, defVal, enum] = Column (fromSql schema) mkColumn [schema, table, name, pos, nullable, colT, updatable, maxlen, precision, defVal, enum] = Column (fromSql schema)
(fromSql table) (fromSql table)
(fromSql name) (fromSql name)
@@ -163,6 +161,8 @@ columns s t conn = do
(fromSql precision) (fromSql precision)
(fromSql defVal) (fromSql defVal)
(splitOn "," <$> fromSql enum) (splitOn "," <$> fromSql enum)
mkColumn _ = error $ "Incomplete column data received for table " ++
t ++ " in schema " ++ s ++ "."
printTables :: String -> Connection -> IO BL.ByteString printTables :: String -> Connection -> IO BL.ByteString
printTables schema conn = JSON.encode <$> tables schema conn printTables schema conn = JSON.encode <$> tables schema conn