schemacrawler / SchemaCrawler

Free database schema discovery and comprehension tool
http://www.schemacrawler.com/
Other
1.58k stars 200 forks source link

Primary keys created using index not registered as primary keys in schemacrawler output #1419

Closed meridsa closed 5 months ago

meridsa commented 6 months ago

Description

I expected a primary key to be detected even when the primary key is created using an index.

CREATE TABLE DB2.SOME_TABLE (
    message_id varchar2(255),
    message_box varchar2(255),
    some_data varchar2(255)
);

CREATE UNIQUE INDEX DB2.UNIQUE_ID_BOX ON DB2.SOME_TABLE ("MESSAGE_ID", "MESSAGE_BOX");

ALTER TABLE DB2.SOME_TABLE ADD PRIMARY KEY ("MESSAGE_ID", "MESSAGE_BOX")
  USING INDEX  ENABLE;

Schemacrawler does not detect this primary key, but does detect this

CREATE TABLE DB1.SOME_TABLE (
    message_id varchar2(255),
    message_box varchar2(255),
    some_data varchar2(255),
    PRIMARY KEY (message_id, message_box)
);

How to Reproduce

I have created a repo that can reproduce the bug:

https://github.com/meridsa/schemacrawler-bugs

Relevant log output

No response

SchemaCrawler Version

16.20.4

Java Version

Eclipse Adoptium OpenJDK 64-Bit Server VM 17.0.5+8

Operating System and Version

Linux 5.15.133.1-microsoft-standard-WSL2

Relational Database System and Version

oracle db 18.4.0 Express Edition

JDBC Driver and Version

Using whatever schemacrawler uses

sualeh commented 6 months ago

@meridsa I will take a look.

sualeh commented 5 months ago

Thanks for the test case. I have reproduced the issue and fixed it.

meridsa commented 5 months ago

Thanks for fixing this :)

sualeh commented 5 months ago

@meridsa Please use SchemaCrawler v16.21.1