schemacrawler / SchemaCrawler

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

Cannot extract check constraints in oracle #1432

Closed meridsa closed 5 months ago

meridsa commented 5 months ago

Description

If I create a table in an ORACLE DB with a check constraint, such as

CREATE TABLE DB1.GUY (
    id varchar2(255) PRIMARY KEY,
    name varchar2(255) NOT NULL,
    favourite_vowel varchar2(1) NOT NULL CHECK (favourite_vowel IN ('A', 'E', 'I', 'O', 'U', 'Y'))
);

CREATE INDEX DB1.NAME_INDEX ON DB1.GUY (name);

I expect the schemacrawler output to include the constraint as the constraint is listed in the sys.ALL_CONSTRAINTS view.

image

However the output is instead:


Tables
========================================================================

GUY                                                              [table]
------------------------------------------------------------------------
  ID                                VARCHAR2(255) NOT NULL      
  NAME                              VARCHAR2(255) NOT NULL      
  FAVOURITE_VOWEL                   VARCHAR2(1) NOT NULL        

Primary Key

                                                           [primary key]
  ID                                                            

Indexes

                                                          [unique index]
  ID                                ascending                   

                                                      [non-unique index]
  NAME                              ascending    

How to Reproduce

You can use meridsa/schemacrawler-bugs to reproduce in a wsl environment by following setup and running ./repro-bug.sh checks.

Relevant log output

No response

SchemaCrawler Version

16.21.1

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

meridsa commented 5 months ago

Thought I had reported a false positive by not using details command. However it replicated using that command as well.

sualeh commented 5 months ago

@meridsa Please look at the SchemaCrawler Oracle test that outputs the check constraints. I have a feeling that this is not a bug, but I will look into it. Please attach your "details" output in your project.

meridsa commented 5 months ago

This works! Thanks!

meridsa commented 5 months ago

For posterity. Using --command=details with --info-level=detailed was the fix.