]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/Injuries.hs
Update TSN.XML modules to use the new Child class.
[dead/htsn-import.git] / src / TSN / XML / Injuries.hs
index af1bc377466d078e71dff41cd73da393d4840200..6af9ad9226feebd20356ab439c1c03a419366dc3 100644 (file)
@@ -3,7 +3,6 @@
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE QuasiQuotes #-}
 {-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE StandaloneDeriving #-}
 {-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE TypeFamilies #-}
 
@@ -32,7 +31,7 @@ import Data.Time ( UTCTime )
 import Data.Typeable ( Typeable )
 import Database.Groundhog (
   countAll,
-  executeRaw,
+  deleteAll,
   migrate,
   runMigration,
   silentMigrationLogger )
@@ -65,6 +64,7 @@ import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
 import TSN.Picklers ( xp_time_stamp )
 import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
 import Xml (
+  Child(..),
   FromXml(..),
   FromXmlFk(..),
   ToDb(..),
@@ -123,10 +123,11 @@ instance ToDb InjuriesListingXml where
   -- | The DB analogue of a 'InjuriesListingXml' is a 'InjuriesListing'
   type Db InjuriesListingXml = InjuriesListing
 
-instance FromXmlFk InjuriesListingXml where
+instance Child InjuriesListingXml where
   -- | Our foreign key points to an 'Injuries'.
   type Parent InjuriesListingXml = Injuries
 
+instance FromXmlFk InjuriesListingXml where
   -- | To convert between a 'InjuriesListingXml' and a
   --   'InjuriesListing', we simply append the foreign key.
   from_xml_fk fk InjuriesListingXml{..} =
@@ -346,8 +347,7 @@ test_on_delete_cascade =
                   migrate a
                   migrate b
                 _ <- dbimport inj
-                -- No idea how 'delete' works, so do this instead.
-                executeRaw False "DELETE FROM injuries;" []
+                deleteAll a
                 count_a <- countAll a
                 count_b <- countAll b
                 return $ count_a + count_b