Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The table editor shows an incorrect foreign key relation with composite foreign keys #3583

Closed
grind-t opened this issue Oct 18, 2021 · 7 comments
Labels
bug Something isn't working frontend Related to supabase dashboard p4 Priority 4

Comments

@grind-t
Copy link

grind-t commented Oct 18, 2021

Bug report

Describe the bug

The table editor shows an incorrect foreign key relation when a table has a composite foreign key.

To Reproduce

  1. Create sample tables:
drop table if exists sample2;
drop table if exists sample1;

create table sample1 (
  pk1 int not null,
  pk2 int not null,
  primary key (pk1, pk2)
);

create table sample2 (
  pk1 int not null,
  pk2 int not null,
  pk3 int not null,
  primary key (pk1, pk2, pk3),
  foreign key (pk1, pk2)
    references sample1 (pk1, pk2)
);
  1. Go to the table editor and open the sample1 table or the sample2 table.
  2. The information about the foreign key relation is incorrect (see screenshots).

Screenshots

image

image

System information

  • OS: Windows 10
  • Browser: Microsoft Edge
@grind-t grind-t added the bug Something isn't working label Oct 18, 2021
@kiwicopple kiwicopple added the frontend Related to supabase dashboard label Dec 28, 2021
@joshenlim
Copy link
Member

Hey there! Sorry it took us so long to get to your issue - we're just looking into this right now

As at the current state of the dashboard the relation descriptions under sample1 doesn't show up (which should be the correct behaviour)

but the relation descriptions under sample2 is still present - this we're looking into a fix

@egor-romanov egor-romanov added the p4 Priority 4 label Jun 14, 2022
@haexhub
Copy link

haexhub commented Aug 9, 2022

How is this topic going?
I'm facing the same problem. The foreign keys are not created correctly, even in the SQL Editor.

@joshenlim joshenlim changed the title The table editor shows an incorrect foreign key relation The table editor shows an incorrect foreign key relation with composite foreign keys Sep 29, 2022
@AntonEriksson978
Copy link

I have the same problem.

My composite foreign key was defined like this:
foreign key (number, course_id) references hole_information (number, course_id),

We can see in the screenshot below how it looks like both course id and number have hole_information.number as its foreign key relation.

Screenshot 2023-04-29 at 15 42 14

@MildTomato
Copy link
Contributor

MildTomato commented May 18, 2023

Hey folks - me and the team here are looking at a visual solution for composite foreign keys today and I'll post an update shortly on what we might propose.

This will be so we officially support composite foreign keys in the dashboard, and issues like this won't be an issue anymore.

We would also like to solve the issue of creating composite foreign keys in the dashboard which will probably mean having some 'mapping UI' so you can easily associate the right columns together to a target table.

will update shortly.

@MildTomato
Copy link
Contributor

MildTomato commented May 19, 2023

Just to let everyone know what the team here thinks we could do:

  • move foreign relations to its own section in table/column side panels in table editor
  • new UI to allow composite keys for foreign constraints.

Introduce new section for foreign keys:
Screenshot 2023-05-19 at 11 34 08 AM

Introduce UI for 'column mapping' when creating a new foreign key:
Screenshot 2023-05-19 at 11 34 58 AM

Introduce UI to display clearly what the foreign keys of a table are, and what table/columns they reference:
Screenshot 2023-05-19 at 11 35 06 AM

We'll also need to change how these are displayed so they support composite:
image

@MildTomato
Copy link
Contributor

We'll probably look at implementing this soon, we are just prioritizing some other areas right now.

Feel free for anyone else to take this though and implement it themselves, if you don't want to wait on the supabase team to implement it.

@MildTomato
Copy link
Contributor

MildTomato commented Jun 14, 2023

Related to #2481 perhaps, as we can maybe handle naming of FK constraints as well

@supabase supabase locked and limited conversation to collaborators Aug 28, 2023
@saltcod saltcod converted this issue into discussion #16916 Aug 28, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working frontend Related to supabase dashboard p4 Priority 4
Projects
No open projects
Status: Done
Development

No branches or pull requests

7 participants