IndexOutOfBoundsException in InformationExtractorJdbcDatabaseMetaDataImpl when retrieving primary key columns when ResultSet is not sorted on "KEY_SEQ"

Description

I'm trying to write a custom schema validator but I ran into an issue when trying to retrieve the primary keys from a TableInformation object.
Apparently the default extractor InformationExtractorJdbcDatabaseMetaDataImpl assumes that java.sql.DatabaseMetaData.getPrimaryKeys() returns the columns in order of "KEY_SEQ" but that is not always the case (in fact the interface makes no such guarantees). The extractor then tries to insert the ColumnInformation out of bounds of the array list.

Environment

None

Activity

Show:
Miguel Diogo
April 30, 2019, 12:42 PM

I originally ran into this issue with an Oracle 12c DB using the Oracle 12.2.0.1 JDBC driver, but I could also reproduce it with H2, so it does not seem to be an isolated JDBC implementation problem.
I attached a test case. The setup is a bit sloppy but it does run into the issue. It includes a simplified version of one of the entities giving me problems.

Assignee

Unassigned

Reporter

Miguel Diogo

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure