QueryDataSet getTable() can only return the first table stored into it. Any additional table added to the QueryDataSet will not be retrievable by calling getTable().
This is caused because getTable() is not overwritten in QueryDataSet and thus AbstractDataSet.getTable() is called instead. QueryDataSet records added tables in QueryDataSet.tables while AbstractDataset saves its list under AbstractDataset.orderedTableNameMap.
The class has two effective OrderedTableNameMap while it should only have one.
Occurs in 2.5.3, but looking at the Git code, the problem still persists.
Thanks for the analyis and report.
I am wondering if you are in progress with or planning on fixing? Creating tests that show the problem is a big help, and also with a fix is best help. If so, either a patch or merge request work well.
I do not have the time now, but what type of fix would you apply? At first glance, I would remove QueryDataSet.tables and have QueryDataSet make use of AbstractDataset.orderedTableNameMap.
Tests are more time consuming than the actual change.
CachedDataSet has the same problem. I removed the list from CachedDataSet and made use of the one inherited by AbstractDataSet and it works fine. I had to do this because it caused my recently added addTable() fonctions to fail.
Upon furth investigation and tests on QueryDataSet, I started to understand how it is working. I believe it needs the two lists after all. I need to spend more time on that class to fully understand what is going on.
There are two other classes that are using a local version of OrderedTableNameMap instead
of the one inherited by AbstractDataSet.
dataset/CachedDataSet.java
dataset/xml/FlatDtdDataSet.java
I will open another bug report to investigate further their cases.
Thanks for the update and continued investigations, Hans.
DatabaseDataSet also has this problem. This one is tricky to fix.