X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FOdds.hs;h=2ad2d93ebb14111896f35fe6638b36a3a40cc424;hb=9f8805d6aa95283e9e2d99259a17cb8c72f6ca62;hp=8061a3e23db2ec2c2eb6c3311ecebcf735fd239e;hpb=f321d21347405c98c24e53ccf4a196dd6fb7cf26;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/Odds.hs b/src/TSN/XML/Odds.hs index 8061a3e..2ad2d93 100644 --- a/src/TSN/XML/Odds.hs +++ b/src/TSN/XML/Odds.hs @@ -535,15 +535,13 @@ instance DbImport Message where odds_id <- insert_xml m forM_ (xml_games m) $ \g -> do - -- Next, we insert the home and away teams. We do this before - -- inserting the game itself because the game has two foreign keys - -- pointing to "teams". + -- First insert the game, keyed to the "odds", + game_id <- insert_xml_fk odds_id g + + -- Next, we insert the home and away teams. away_team_id <- insert_xml_or_select (xml_away_team g) home_team_id <- insert_xml_or_select (xml_home_team g) - -- Now insert the game, keyed to the "odds", - game_id <- insert_xml_fk odds_id g - -- Insert a record into odds_games__teams mapping the -- home/away teams to this game. Use the full record syntax -- because the types would let us mix up the home/away teams.