oracle / quicksql

A library for generating DDL SQL and entity-relationship-diagrams from Quick SQL code
Universal Permissive License v1.0
52 stars 11 forks source link

Unique constraint name unexpectedly leaves out table prefix if used #63

Closed stevemuench closed 5 months ago

stevemuench commented 5 months ago

If you explicitly name your table with a prefix, its name is used correctly in constraint names. For example:

e01_t
   s vc20 /nn /unique

This produces the expected result of:

create table e01_t (
    id    number generated by default on null as identity
          constraint e01_t_id_pk primary key,
    s     varchar2(20 char)
          constraint e01_t_s_unq unique not null
);

However, if you use the #prefix setting to add the prefix, then primary key constraint correctly includes the e01 table prefix, but the unique constraint prefix does not.

t
   s vc20 /nn /unique
#prefix: e01

This produces the unexpected result (missing the e01_ prefix in the unique constraint name:

create table e01_t (
    id    number generated by default on null as identity
          constraint e01_t_id_pk primary key,
    s     varchar2(20 char)
          constraint t_s_unq unique not null
);