Menu

#222 MySQL AmbiguousTableNameException incorrectly thrown

closed-fixed
Bug (232)
5
2009-01-17
2009-01-06
No

After upgrading to v2.4.2 from v2.3.0, AmbiguousTableNameException is incorrectly thrown for valid data sets. I've isolated the problem and it has to do with the order of elements in the FlatXmlDataSet.

The following dataset works as expected:

<dataset>
<users id="1" email="a@acme.com" password="blabbl@h"/>
<users id="2" email="b@acme.com" password="yoyo10"/>

<user_roles user_id="1" name="USER"/>
<user_roles user_id="2" name="ADMIN"/>
</dataset>

While this dataset does NOT work (though it used to with versions <= 2.3.0):

<dataset>
<users id="1" email="a@acme.com" password="blabbl@h"/>
<user_roles user_id="1" name="USER"/>

<users id="2" email="b@acme.com" password="yoyo10"/>
<user_roles user_id="2" name="ADMIN"/>
</dataset>

Note that the only difference is the ordering of the elements.

I've created a very stripped down example which demonstrates this behavior. It's available via anonymous SVN: http://svn.carbonfive.com/public/christian/dbunit-mysql-issue/trunk/. Please see the root-level readme.txt for detailed instructions to reproduce the problem.

Other details: MySQL 5.0.67 on Windows, Java 1.5 and 1.6.

Discussion

  • Christian Nelson

    Some additional information:

    1) The change in behavior was introduced between 2.3.0 and 2.4.0.
    2) This specific error only seems to happen with MySQL under Windows.
    3) Interestingly, both of the tests in the aforementioned sample project fail when run against MySQL running under Linux. Note that both tests pass regardless of db server platform with 2.3.0.

     
  • matthias g

    matthias g - 2009-01-08

    Hi Christian,

    First of all thanks a lot for your great bug report! I wished everybody provided such good work!
    I investigated this and I currently think that you made use of a corner case - the iterator (internally used for your use case) worked in 2.3 because no duplicate check was performed. This changed with 2.4.

    Did you try to invoke flatXmlDataSet.getTable("user_roles") on your DataSet? I'm quite sure that it throws an AmbiguousTableNameException.

    This needs to be discussed on the developer forums. I think the following question should be looked at:
    If the same table occurs twice having any different tables inbetween, should it be added to the Java-Object representing the first table or should a new ITable object be created every time (as it was in your "corner"-case)?

    Best regards,
    mat

     
  • Christian Nelson

    I'm happy to talk more about it on the forum, but really, as long as it behaves that same as the older versions I don't really have a preference for what's happening under the covers. :) It seems to me that it's not just a corner case as grouping statements in different ways can dramatically improve readability (it's common on the dozen or so projects we've used dbunit on).

     
  • Carlos Marcos

    Carlos Marcos - 2009-01-15

    Hi,

    i am getting exactly the same error!
    the difference, is that i'm using Oracle10g database (on linux and java 1.6)

    Thanks,

     
  • matthias g

    matthias g - 2009-01-16

    Hi there,

    I agree that it improves readability and I fixed this for FlatXmlDataSet and XmlDataSet (SVN rev. 941/trunk). Now the IDataSet is completely valid, so if you a flatXmlDataSet.getTable("user_roles") it also works. Under the covers the table data is merged into a single ITable object.

    Please retest my changes and tell me if it works. You can retrieve the latest snapshot from parabuild at

    http://parabuild.viewtier.com:8080/parabuild/build/results.htm?buildrunid=11393

    Thanks and regards,
    matthias

     
  • matthias g

    matthias g - 2009-01-16
    • status: open --> pending-fixed
     
  • Christian Nelson

    Matthias:

    2.4.3-SNAPSHOT works nicely in both my test harness and our application (the *real* test) where we're making very heavy use of dbunit. Thank you for looking into this and for the fast turn-around, I appreciate it. I'm excited for 2.4.3's release.

    Cheers,
    Christian

     
  • Christian Nelson

    • status: pending-fixed --> open-fixed
     
  • matthias g

    matthias g - 2009-01-17
    • status: open-fixed --> closed-fixed
     
  • matthias g

    matthias g - 2009-01-17

    Hi Christian,

    thanks for testing - fine that it works now for you. I hope that we can release the 2.4.3 soon - I will ask Roberto to do so in the next couple of days.

    I will close this issue now.

    Regards,
    matthias

     

Log in to post a comment.