import TSN.Codegen (
tsn_codegen_config )
import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
+import TSN.Picklers ( xp_team_id )
import TSN.XmlImport ( XmlImport(..) )
import Xml ( FromXml(..), pickle_unpickle, unpickleable )
data OddsGameHomeTeamXml =
OddsGameHomeTeamXml {
- xml_home_team_id :: Int,
+ xml_home_team_id :: String, -- ^ These are three-character IDs.
xml_home_rotation_number :: Int,
xml_home_abbr :: String,
xml_home_team_name :: String,
data OddsGameTeam =
OddsGameTeam {
- db_team_id :: Int,
+ db_team_id :: String, -- ^ The home/away team IDs are 3 characters
db_abbr :: String,
db_team_name :: String }
deriving (Eq, Show)
data OddsGameAwayTeamXml =
OddsGameAwayTeamXml {
- xml_away_team_id :: Int,
+ xml_away_team_id :: String, -- ^ These are 3 character IDs.
xml_away_rotation_number :: Int,
xml_away_abbr :: String,
xml_away_team_name :: String,
dbName: odds_games_teams
constructors:
- name: OddsGameTeam
+ fields:
+ - name: db_team_id
+ type: varchar(3)
uniques:
- name: unique_odds_games_team
type: constraint
xpElem "HomeTeam" $
xpWrap (from_tuple, to_tuple) $
xp5Tuple
- (xpElem "HomeTeamID" xpInt)
+ (xpElem "HomeTeamID" xp_team_id)
(xpElem "HomeRotationNumber" xpInt)
(xpElem "HomeAbbr" xpText)
(xpElem "HomeTeamName" xpText)
xpElem "AwayTeam" $
xpWrap (from_tuple, to_tuple) $
xp5Tuple
- (xpElem "AwayTeamID" xpInt)
+ (xpElem "AwayTeamID" xp_team_id)
(xpElem "AwayRotationNumber" xpInt)
(xpElem "AwayAbbr" xpText)
(xpElem "AwayTeamName" xpText)
[ check "pickle composed with unpickle is the identity"
"test/xml/Odds_XML.xml",
+ check "pickle composed with unpickle is the identity (non-int team_id)"
+ "test/xml/Odds_XML-noninteger-team-id.xml",
+
check "pickle composed with unpickle is the identity (positive(+) line)"
"test/xml/Odds_XML-positive-line.xml" ]
where
[ check "unpickling succeeds"
"test/xml/Odds_XML.xml",
+ check "unpickling succeeds (non-int team_id)"
+ "test/xml/Odds_XML-noninteger-team-id.xml",
+
check "unpickling succeeds (positive(+) line)"
"test/xml/Odds_XML-positive-line.xml" ]
where