]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/Odds.hs
Export the Game types from TSN.XML.Odds.
[dead/htsn-import.git] / src / TSN / XML / Odds.hs
index 8cfe4ce35679eb7bd1fe49d54d3358e109b0085b..6b7d4ab9d831d7fd10dd16d6ca252c0fa1d0d142 100644 (file)
@@ -3,7 +3,6 @@
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE QuasiQuotes #-}
 {-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE StandaloneDeriving #-}
 {-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE TypeFamilies #-}
 
 --   other... disorganized... information.
 --
 module TSN.XML.Odds (
+  OddsGameAwayTeamXml(..), -- Used in TSN.XML.JFile
+  OddsGameHomeTeamXml(..), -- Used in TSN.XML.JFile
+  OddsGameTeam(..),        -- Used in TSN.XML.JFile
+  dtd,
   pickle_message,
   -- * Tests
   odds_tests,
@@ -32,7 +35,7 @@ import Database.Groundhog (
   (=.),
   (==.),
   countAll,
-  executeRaw,
+  deleteAll,
   insert_,
   migrate,
   runMigration,
@@ -66,7 +69,7 @@ import Text.XML.HXT.Core (
 import TSN.Codegen (
   tsn_codegen_config )
 import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
-import TSN.Picklers ( xp_date, xp_time, xp_time_stamp )
+import TSN.Picklers ( xp_date_padded, xp_time, xp_time_stamp )
 import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
 import Xml (
   FromXml(..),
@@ -77,6 +80,12 @@ import Xml (
   unsafe_unpickle )
 
 
+-- | The DTD to which this module corresponds. Used to invoke dbimport.
+--
+dtd :: String
+dtd = "Odds_XML.dtd"
+
+
 --
 -- DB/XML data types
 --
@@ -686,7 +695,7 @@ pickle_game =
   xpWrap (from_tuple, to_tuple) $
   xp6Tuple
     (xpElem "GameID" xpInt)
-    (xpElem "Game_Date" xp_date)
+    (xpElem "Game_Date" xp_date_padded)
     (xpElem "Game_Time" xp_time)
     pickle_away_team
     pickle_home_team
@@ -793,12 +802,12 @@ test_unpickle_succeeds = testGroup "unpickle tests"
 --
 test_on_delete_cascade :: TestTree
 test_on_delete_cascade = testGroup "cascading delete tests"
-    [ check "deleting odds deleted its children"
+    [ check "deleting odds deletes its children"
           "test/xml/Odds_XML.xml"
           13 -- 5 casinos, 8 teams
     ,
 
-    check "deleting odds deleted its children (non-int team_id)"
+    check "deleting odds deletes its children (non-int team_id)"
           "test/xml/Odds_XML-noninteger-team-id.xml"
           51 -- 5 casinos, 46 teams
     ,
@@ -830,8 +839,7 @@ test_on_delete_cascade = testGroup "cascading delete tests"
                     migrate e
                     migrate f
                   _ <- dbimport odds
-                  -- No idea how 'delete' works, so do this instead.
-                  executeRaw False "DELETE FROM odds;" []
+                  deleteAll a
                   count_a <- countAll a
                   count_b <- countAll b
                   count_c <- countAll c