Closed notramo closed 1 year ago
Thanks for reporting this. Can you include a full table schema (CREATE TABLE statements) and the output of \d companies
and \d employees
?
This is a minimal database, only the fields needed for reproducing this bug.
I noticed that if the foreign key constraint is created on a database that doesn't have a column with the referenced column name (e.g. the foreign key constraint references the id
column of the other table, but there is no id
column in the current table), the result in the \d
command output is ()
.
In the first example, there is only the company_id
field in the employees
table, so the last line of the output shows ()
after the REFERENCES
statement (last line on the screenshot).
After adding an id
column to employees
, it will show it as employees(id)
.
Thanks for all the details. There was an obvious bug and we were missing tests for MySQL.
The
\d <table_name>
command returns incorrect foreign key constraint on MariaDB (not tested other database systems).The output says the foreign key references the table it is in. E.g. there are
companies
andemployees
each employee has acompany_id
which is a foreign key index oncompanies(id)
, butusql
incorrectly shows in\d employees
that it's onemployees(id)
.