import TSN.Codegen (
tsn_codegen_config )
import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
-import TSN.Picklers ( xp_date, xp_tba_time, xp_time_stamp )
+import TSN.Picklers ( xp_date_padded, xp_tba_time, xp_time_stamp )
import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
import Xml (
+ Child(..),
FromXml(..),
FromXmlFk(..),
ToDb(..),
-- * AutoRacingScheduleListing/AutoRacingScheduleListingXml
-- | Database representation of a \<Listing\> contained within a
--- \<Message\>. We combine the race date/time into a single
+-- \<message\>. We combine the race date/time into a single
-- race_time, drop the race results list, and add a foreign key to
-- our parent.
--
--
type Db AutoRacingScheduleListingXml = AutoRacingScheduleListing
-instance FromXmlFk AutoRacingScheduleListingXml where
+
+instance Child AutoRacingScheduleListingXml where
-- | Each 'AutoRacingScheduleListingXml' is contained in (i.e. has a
-- foreign key to) a 'AutoRacingSchedule'.
--
type Parent AutoRacingScheduleListingXml = AutoRacingSchedule
+
+instance FromXmlFk AutoRacingScheduleListingXml where
-- | To convert an 'AutoRacingScheduleListingXml' to an
-- 'AutoRacingScheduleListing', we add the foreign key and drop
-- the 'xml_race_results'. We also mash the date/time together
deriving (Eq, Show)
--- * AutoRacingScheduleListingRaceResultRaceResultListing /
--- AutoRacingScheduleListingRaceResultRaceResultListingXml
+-- * AutoRacingScheduleListingRaceResultRaceResultListing / AutoRacingScheduleListingRaceResultRaceResultListingXml
--
-- Sorry about the names yo.
--
AutoRacingScheduleListingRaceResultRaceResultListing
-instance FromXmlFk AutoRacingScheduleListingRaceResultRaceResultListingXml where
+instance Child AutoRacingScheduleListingRaceResultRaceResultListingXml where
-- | Each 'AutoRacingScheduleListingRaceResultRaceResultListingXml'
-- is contained in (i.e. has a foreign key to) an
-- 'AutoRacingScheduleListing'. We skip the intermediate
type Parent AutoRacingScheduleListingRaceResultRaceResultListingXml =
AutoRacingScheduleListing
+
+instance FromXmlFk AutoRacingScheduleListingRaceResultRaceResultListingXml where
-- | To convert an
-- 'AutoRacingScheduleListingRaceResultRaceResultListingXml' to an
-- 'AutoRacingScheduleListingRaceResultRaceResultListing', we just
xpElem "Listing" $
xpWrap (from_tuple, to_tuple) $
xp10Tuple (xpElem "RaceID" xpInt)
- (xpElem "Race_Date" xp_date)
+ (xpElem "Race_Date" xp_date_padded)
(xpElem "Race_Time" xp_tba_time)
(xpElem "RaceName" xpText)
(xpElem "TrackName" xpText)