emit references for columns with foreign keys

This commit is contained in:
Adam C. Baker
2014-10-08 16:38:12 -07:00
parent e17c51e2f1
commit ee02a98cf2
2 changed files with 70 additions and 5 deletions
+4
View File
@@ -36,6 +36,9 @@ data ForeignKey = ForeignKey {
fkTable::String, fkCol::String
} deriving (Eq, Show)
instance JSON.ToJSON ForeignKey where
toJSON fk = JSON.object ["table".=fkTable fk, "column".=fkCol fk]
foreignKeys :: String -> String -> Connection -> IO (Map.Map String ForeignKey)
foreignKeys schema table conn = do
r <- quickQuery conn
@@ -78,6 +81,7 @@ instance JSON.ToJSON Column where
, "updatable" .= colUpdatable c
, "maxLen" .= colMaxLen c
, "precision" .= colPrecision c
, "references".= colFK c
, "default" .= colDefault c ]
data TableOptions = TableOptions {