Skip to content

V5 - Naming conflict when two columns of my table reference the same enum table #215

Open
@LouisLec

Description

When executing the following SQL schema, I encounter the error:
A naming conflict has occurred - two entities have tried to define the same key 'myEnum'.

create table publ.my_enum (
    type text primary key,
    description text
);
grant select on publ.my_enum to :DATABASE_AUTHENTICATOR;
comment on table publ.my_enum is E'@enum';

insert into publ.my_enum values
    ('ONE', 'One'),
    ('TWO', 'Two'),
    ('THREE', 'Three');

create table publ.my_table (
    id uuid not null default uuid_generate_v4() primary key unique, 
    first_field text not null references publ.my_enum(type),
    second_field text not null references publ.my_enum(type)
);

grant select on table publ.my_table to :DATABASE_VISITOR;

create index on publ.my_table(first_field);
create index on publ.my_table(second_field);

It seems the issue arises because both first_field and second_field reference the same enum table (publ.my_enum).

Renaming the fields to include the _id suffix (first_field_id and second_field_id) resolves the conflict, but this workaround feels inappropriate for this particular use case, as the fields don't conceptually represent IDs.

Would it be possible for the plugin to handle scenarios like this without requiring such workarounds?

Thank you for your time and support!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions