]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/InjuriesDetail.hs
Update TSN.XML modules to use the new Child class.
[dead/htsn-import.git] / src / TSN / XML / InjuriesDetail.hs
index e5d572e7a504f37f0ed994d1c495bfd55bc41407..0eb3e238b99b6a986701c35edd6eee724a417298 100644 (file)
@@ -2,7 +2,6 @@
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE QuasiQuotes #-}
 {-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE StandaloneDeriving #-}
 {-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE TypeFamilies #-}
 
@@ -13,6 +12,7 @@
 --   real meat.
 --
 module TSN.XML.InjuriesDetail (
+  dtd,
   pickle_message,
   -- * Tests
   injuries_detail_tests,
@@ -29,7 +29,7 @@ import Data.Tuple.Curry ( uncurryN )
 import Database.Groundhog (
   DefaultKey,
   countAll,
-  executeRaw,
+  deleteAll,
   migrate,
   runMigration,
   silentMigrationLogger )
@@ -59,6 +59,7 @@ import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
 import TSN.Picklers( xp_date, xp_time_stamp )
 import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
 import Xml (
+  Child(..),
   FromXml(..),
   FromXmlFk(..),
   ToDb(..),
@@ -67,6 +68,13 @@ import Xml (
   unsafe_unpickle )
 
 
+
+-- | The DTD to which this module corresponds. Used to invoke dbimport.
+--
+dtd :: String
+dtd = "Injuries_Detail_XML.dtd"
+
+
 --
 -- Data types
 --
@@ -153,11 +161,14 @@ instance ToDb InjuriesDetailListingXml where
   --   'InjuriesDetailListing'.
   type Db InjuriesDetailListingXml = InjuriesDetailListing
 
-instance FromXmlFk InjuriesDetailListingXml where
+
+instance Child InjuriesDetailListingXml where
   -- | Each 'InjuriesDetailListingXml' is contained in an
   --   'InjuriesDetail'.
   type Parent InjuriesDetailListingXml = InjuriesDetail
 
+
+instance FromXmlFk InjuriesDetailListingXml where
   -- | Construct a 'InjuriesDetailListing' from a
   --   'InjuriesDetailListingXml' and a foreign key to a
   --   'InjuriesDetail'.
@@ -227,12 +238,15 @@ instance ToDb InjuriesDetailListingPlayerListingXml where
   type Db InjuriesDetailListingPlayerListingXml =
     InjuriesDetailListingPlayerListing
 
-instance FromXmlFk InjuriesDetailListingPlayerListingXml where
+
+instance Child InjuriesDetailListingPlayerListingXml where
   -- | Each 'InjuriesDetailListingPlayerListingXml' is contained in an
   --   'InjuriesDetailListing'.
   --
   type Parent InjuriesDetailListingPlayerListingXml = InjuriesDetailListing
 
+
+instance FromXmlFk InjuriesDetailListingPlayerListingXml where
   -- | To construct a 'InjuriesDetailListingPlayerListing' from a
   --   'InjuriesDetailListingPlayerListingXml' we need to supply a
   --   foreign key to an 'InjuriesDetailListing'.
@@ -455,8 +469,7 @@ test_on_delete_cascade = testGroup "cascading delete tests"
                     migrate b
                     migrate c
                   _ <- dbimport inj
-                  -- No idea how 'delete' works, so do this instead.
-                  executeRaw False "DELETE FROM injuries_detail;" []
+                  deleteAll a
                   count_a <- countAll a
                   count_b <- countAll b
                   count_c <- countAll c