X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FInjuriesDetail.hs;h=0eb3e238b99b6a986701c35edd6eee724a417298;hb=b0a87f9323223a0af538184940b35a081f5763af;hp=4356eb60be9c344267eaea850092d5aed632cac5;hpb=a0853ebe00e630b7d50f97949d4dd45c602bd454;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/InjuriesDetail.hs b/src/TSN/XML/InjuriesDetail.hs index 4356eb6..0eb3e23 100644 --- a/src/TSN/XML/InjuriesDetail.hs +++ b/src/TSN/XML/InjuriesDetail.hs @@ -2,7 +2,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} @@ -30,7 +29,7 @@ import Data.Tuple.Curry ( uncurryN ) import Database.Groundhog ( DefaultKey, countAll, - executeRaw, + deleteAll, migrate, runMigration, silentMigrationLogger ) @@ -60,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(..), @@ -161,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'. @@ -235,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'. @@ -463,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