import TSN.Picklers ( xp_time_stamp )
import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
import Xml (
+ Child(..),
FromXml(..),
FromXmlFk(..),
ToDb(..),
data InjuriesListingXml =
InjuriesListingXml {
xml_team :: InjuriesTeam,
- xml_teamno :: Maybe Int,
+ xml_teamno :: Maybe String, -- ^ Can contain non-numerics, e.g. \"ZR2\"
xml_injuries :: String,
xml_updated :: Maybe Bool }
deriving (Eq, Show)
InjuriesListing {
db_injuries_id :: DefaultKey Injuries,
db_team :: InjuriesTeam,
- db_teamno :: Maybe Int,
+ db_teamno :: Maybe String, -- ^ Can contain non-numerics, e.g. \"ZR2\"
db_injuries :: String,
db_updated :: Maybe Bool }
-- | The DB analogue of a 'InjuriesListingXml' is a 'InjuriesListing'
type Db InjuriesListingXml = InjuriesListing
-instance FromXmlFk InjuriesListingXml where
+instance Child InjuriesListingXml where
-- | Our foreign key points to an 'Injuries'.
type Parent InjuriesListingXml = Injuries
+instance FromXmlFk InjuriesListingXml where
-- | To convert between a 'InjuriesListingXml' and a
-- 'InjuriesListing', we simply append the foreign key.
from_xml_fk fk InjuriesListingXml{..} =
xpElem "listing" $
xpWrap (from_tuple, to_tuple) $
xp4Tuple pickle_injuries_team
- (xpOption $ xpElem "teamno" xpInt)
+ (xpOption $ xpElem "teamno" xpText)
(xpElem "injuries" xpText)
(xpOption $ xpElem "updated" xpPrim)
where