Skip to content
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

Bad foreign key error message #3075

Closed
bheni opened this issue Mar 23, 2022 · 3 comments
Closed

Bad foreign key error message #3075

bheni opened this issue Mar 23, 2022 · 3 comments

Comments

@bheni
Copy link
Contributor

bheni commented Mar 23, 2022

steps:

~/datasets>mkdir bug
~/datasets>cd bug
~/datasets/bug>dolt init
Successfully initialized dolt data repository.
~/datasets/bug>echo 'CREATE TABLE x (
>   id int PRIMARY KEY NOT NULL
> );
>
> CREATE TABLE y (
>   id int PRIMARY KEY NOT NULL
> );
>
> ALTER TABLE x ADD COLUMN x_id_fk int;
> ALTER TABLE x ADD FOREIGN KEY (x_id_fk) REFERENCES x(id) ON DELETE RESTRICT;
> ALTER TABLE x DROP COLUMN x_id_fk;' | dolt sql

output:

error on line 11 for query
ALTER TABLE x DROP COLUMN x_id_fk: cannot drop column `x_id_fk` as it is used in foreign key `10069`
cannot drop column `x_id_fk` as it is used in foreign key `10069`
@fulghum fulghum added bug Something isn't working and removed bug Something isn't working labels Mar 24, 2022
@fulghum
Copy link
Contributor

fulghum commented Mar 24, 2022

Looks like this is consistent with MySQL's behavior. Here's what I get against MySQL:

mysql> ALTER TABLE x DROP COLUMN x_id_fk;
ERROR 1828 (HY000): Cannot drop column 'x_id_fk': needed in a foreign key constraint 'x_ibfk_1'

@zachmu zachmu changed the title Error deleting foreign key column Bad foreign key error message Mar 29, 2022
@zachmu
Copy link
Member

zachmu commented Mar 29, 2022

Still a bug here, which is that the error message doesn't name the constraint (looks like it's using a tag value?)

@zachmu
Copy link
Member

zachmu commented Mar 29, 2022

Duplicate of #3064

@zachmu zachmu marked this as a duplicate of #3064 Mar 29, 2022
@zachmu zachmu closed this as completed Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants