Menu

#405 Only single table with missing primary key failling

v2.5.*
pending
None
(not fixed)
5
2018-08-20
2017-11-01
Puneet Behl
No

When i am trying to import a db where there is no primary key mapped i am facing the issue.
The solution is to use IColumnFilter and add this in config but this is failling in our scneario.

We have 700 tables and in which only 2 tables are not having id.
Also there is no condition of primary key nomenclature and people have added it in different ways.

If i am implimenting IColumnFilter then i have to specify the id for all the tables which is not acceptable and your implimentation. Without filter the keyis fetched from getPrimaryKeyNames() of DatabaseTableMetaData.

The proposed solution is changing the DatabaseTableMetaData.java with this implimentation in getPrimaryKeys

    if (primaryKeysFilter != null) {
                _primaryKeys = Columns.getColumns(getTableName(), getColumns(),
                        primaryKeysFilter);
                if (null !=_primaryKeys &&_primaryKeys.length<=0) {
                    String[] pkNames = getPrimaryKeyNames();
                    _primaryKeys = Columns.getColumns(pkNames, getColumns());
                }
            } else {
                String[] pkNames = getPrimaryKeyNames();
                _primaryKeys = Columns.getColumns(pkNames, getColumns());
            }

Discussion

  • Jeff Jensen

    Jeff Jensen - 2017-11-03

    Hi Puneet,
    Thanks for finding a solution and reporting the problem.

    To have it applied to dbUnit code, please create one or more tests proving the problem exists and the change fixes it. Then make a merge request for them or attach a patch to this issue.

    We can then review and apply it when it is ready.

    Let us know if you need any help.

     
  • Jeff Jensen

    Jeff Jensen - 2017-11-03
    • status: open --> pending
    • assigned_to: Jeff Jensen
     
  • Puneet Behl

    Puneet Behl - 2017-11-07

    Hi Jeff,

    Merge request with code change and DBunit has been pushed to trunk. Kindly check once.

    https://sourceforge.net/p/dbunit/code.git/merge-requests/38/

     
    • Jeff Jensen

      Jeff Jensen - 2017-11-08

      Hi Puneet, I posted MR feedback today and also posting here in case you don't receive MR update notifications.

       
  • Puneet Behl

    Puneet Behl - 2017-11-09
     
    • Jeff Jensen

      Jeff Jensen - 2018-08-20

      Hi Puneet, just following up - did you see the issues we wrote many months ago on the merge request? If you are still interested in this improvement, please see the MR.

       

Log in to post a comment.

MongoDB Logo MongoDB