+
+-- Team Breakdown
+data MLBBoxScoreTeamBreakdown =
+ MLBBoxScoreTeamBreakdown {
+ db_runs :: Int,
+ db_hits :: Int,
+ db_errors :: Int }
+data MLBBoxScoreTeamBreakdownXml =
+ MLBBoxScoreTeamBreakdownXml {
+ xml_runs_by_innings :: [MLBBoxScoreRunsByInningsXml],
+ xml_runs :: Int,
+ xml_hits :: Int,
+ xml_errors :: Int }
+ deriving (Eq, GHC.Generic, Show)
+
+
+-- | For 'Generics.to_tuple'.
+instance Generic MLBBoxScoreTeamBreakdownXml
+
+instance ToDb MLBBoxScoreTeamBreakdownXml where
+ -- | The database analogue of a 'MLBBoxScoreTeamBreakdownXml' is
+ -- a 'MLBBoxScoreTeamBreakdown'.
+ --
+ type Db MLBBoxScoreTeamBreakdownXml = MLBBoxScoreTeamBreakdown
+
+
+-- | The 'FromXml' instance for 'MLBBoxScoreTeamBreakdownXml' is
+-- required for the 'XmlImport' instance.
+--
+instance FromXml MLBBoxScoreTeamBreakdownXml where
+ -- | To convert a 'MLBBoxScoreTeamBreakdownXml' to an
+ -- 'MLBBoxScoreTeamBreakdown', we just drop the
+ -- 'xml_runs_by_innings'.
+ --
+ from_xml MLBBoxScoreTeamBreakdownXml{..} =
+ MLBBoxScoreTeamBreakdown {
+ db_runs = xml_runs,
+ db_hits = xml_hits,
+ db_errors = xml_errors }
+
+instance XmlImport MLBBoxScoreTeamBreakdownXml
+
+-- Runs by innings
+data MLBBoxScoreRunsByInnings =
+ MLBBoxScoreRunsByInnings {
+ db_mlb_box_scores_team_breakdowns_id :: DefaultKey
+ MLBBoxScoreTeamBreakdown,
+ db_runs_by_innings_inning_number :: Int,
+ db_runs_by_innings_runs :: Int }
+
+data MLBBoxScoreRunsByInningsXml =
+ MLBBoxScoreRunsByInningsXml {
+ xml_runs_by_innings_inning_number :: Int,
+ xml_runs_by_innings_runs :: Int }
+ deriving (Eq, GHC.Generic, Show)
+
+
+-- * MLBBoxScore_MLBBoxScoreTeamSummary
+
+-- | Mapping between 'MLBBoxScore' records and
+-- 'MLBBoxScoreTeamSummary' records in the database. We don't use
+-- the names anywhere, so we let Groundhog choose them.
+--
+data MLBBoxScore_MLBBoxScoreTeamBreakdown =
+ MLBBoxScore_MLBBoxScoreTeamBreakdown
+ (DefaultKey MLBBoxScore)
+ (DefaultKey MLBBoxScoreTeamBreakdown) -- Away team
+ (DefaultKey MLBBoxScoreTeamBreakdown) -- Home team
+
+
+
+-- | For 'Generics.to_tuple'.
+--
+instance Generic MLBBoxScoreRunsByInningsXml
+
+
+instance ToDb MLBBoxScoreRunsByInningsXml where
+ -- | The database analogue of a 'MLBBoxScoreRunsByInningsXml' is
+ -- a 'MLBBoxScoreRunsByInnings'.
+ --
+ type Db MLBBoxScoreRunsByInningsXml = MLBBoxScoreRunsByInnings
+
+
+instance Child MLBBoxScoreRunsByInningsXml where
+ -- | Each 'MLBBoxScoreRunsByInningsXml' is contained in (i.e. has a
+ -- foreign key to) a 'MLBBoxScoreTeamBreakdownXml'.
+ --
+ type Parent MLBBoxScoreRunsByInningsXml = MLBBoxScoreTeamBreakdown
+
+
+instance FromXmlFk MLBBoxScoreRunsByInningsXml where
+ -- | To convert an 'MLBBoxScoreRunsByInningsXml' to an
+ -- 'MLBBoxScoreRunsByInnings', we add the foreign key and copy
+ -- everything else verbatim.
+ --
+ from_xml_fk fk MLBBoxScoreRunsByInningsXml{..} =
+ MLBBoxScoreRunsByInnings {
+ db_mlb_box_scores_team_breakdowns_id = fk,
+ db_runs_by_innings_inning_number = xml_runs_by_innings_inning_number,
+ db_runs_by_innings_runs = xml_runs_by_innings_runs }
+
+
+-- | This allows us to insert the XML representation
+-- 'MLBBoxScoreRunsByInningsXml' directly.
+--
+instance XmlImportFk MLBBoxScoreRunsByInningsXml
+
+
+
+