Closed emkookmer closed 6 years ago
@elazar, here is the new pull request to master as you suggested in pull request #138
Is throwing an exception the most desirable course of action here? Would returning null be a potentially feasible alternative?
I think it's the most desirable course, because the field was already define in the table structure and missing from the dataset. Here is an example seed which should go wrong and trigger my exception.
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="AdviesFactuur">
<table_structure name="TBL_Actions">
<field Field="ID" Type="int(10) unsigned" Null="NO" Key="PRI" Extra="auto_increment" Comment="" />
<field Field="State" Type="int(10) unsigned" Null="NO" Key="MUL" Extra="" Comment="" />
<field Field="VIPPeriod" Type="decimal(4,0)" Null="NO" Key="" Extra="" Comment="Period in Days" />
<field Field="NormPeriod" Type="decimal(4,0)" Null="NO" Key="" Extra="" Comment="Period in Days" />
<key Table="TBL_Actions" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID" Collation="A" Cardinality="5" Null="" Index_type="BTREE" Comment="" />
</table_structure>
<table_data name="TBL_Actions">
<row>
<field name="ID">2</field>
<field name="State">6</field>
<field name="VIPPeriod">0</field>
<!-- NOTE the missing NormPeriod field here -->
</row>
</table_data>
</database>
</mysqldump>
Fair enough. I can see from doing a local test dump that mysqldump
uses an attribute on the row to specify a null
value for a column (see below), so it appears you're right: if a column is missing, something is likely wrong with the dump file.
<row>
<field name="test" xsi:nil="true" />
</row>
Any chance you could add a test case for this change?
This branch has conflicts that must be resolved.
A resubmit of pull request #138, but this time to master
I was updating my XML seeds, but in doing so remove too much. DBUnit gave an error while parsing the modified seed and throw a unknown index exception. As it was unclear what happened, I started digging found that there was no check whereof a field was found or not. So I came up with this solution.