|
From: Adolfo <ado...@ya...> - 2013-08-10 17:36:46
|
Hi all. First of all, I'd like to congratulate all members for this nice job DBUnit. I'd like to post an issue and if possible apply a patch to something I think will be better for end users of dbunit lib. First I'll give you some detail about the problem I was having trying to use the lib in a specific scenario: Let's consider the following dataset: <dataset> <Category id="10" name="Games"/> <Category id="1000" name="Sports"/> <Product id="1" description="blender" name="blender" price="50.00"/> <Product id="6" description="PS3 Battlefield 3" name="Battlefield" price="15.90" category_id="10"/> <Product id="7" description="Super Street Fighter IV" name="Street Fighter IV" price="16.00" category_id="10"/> </dataset> Looking at the dataset note that Product table have 5 columns: id, description, name, price and category_id (because of a relationship) As category_id isn't required, the first row being described does not set category_id. The problem is: at AbstractBatchOperation.execute method, a statement will be generated only when ignoreMapping is null or equalsIgnoreMapping returns false as follows: // If current row have a different ignore value mapping than // previous one, we generate a new statement if (ignoreMapping == null || !equalsIgnoreMapping(ignoreMapping, table, row)) To do my unit tests running fine I had to change the order of my rows inside the dataset as follows (so the correct statement were generated correctly): <dataset> <Category id="10" name="Games"/> <Category id="1000" name="Sports"/> <Product id="6" description="PS3 Battlefield 3" name="Battlefield" price="15.90" category_id="10"/> <Product id="7" description="Super Street Fighter IV" name="Street Fighter IV" price="16.00" category_id="10"/> <Product id="1" description="blender" name="blender" price="50.00"/> </dataset> What do you think to consider when the columns change when iterating throughout the rows? Discovering what was happening was time consuming and I think end users of the lib can still stop using when falling into the same scenario. Best regards and Thank you. Adolfo Eloy |