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

dolt import table Foreign Key NOT NULL violation error is not helpful #2118

Closed
abmyii opened this issue Sep 10, 2021 · 1 comment
Closed
Labels

Comments

@abmyii
Copy link
Contributor

abmyii commented Sep 10, 2021

When trying to insert NULL into a NOT NULL FK field, the error given is something like this:

Rows Processed: 1, Additions: 1, Modifications: 0, Had No Effect: 0

A bad row was encountered while moving data.
Bad Row: 
invalid column: naics_2017
These can be ignored using the '--continue'

Though the column name shown is correct, this doesn't mention anywhere that issue is a NOT NULL violation.

To reproduce:

$ dolt sql <<SQL
 CREATE TABLE naics (
   naics_2017 char(6) NOT NULL,
   PRIMARY KEY (naics_2017)
 );
 CREATE TABLE businesses (
   name varchar(180) NOT NULL,
   naics_2017 char(6) NOT NULL,
   PRIMARY KEY (name),
   KEY naics_2017 (naics_2017),
   CONSTRAINT naics FOREIGN KEY (naics_2017) REFERENCES naics (naics_2017)
 );
 INSERT INTO naics VALUES ("100");
SQL

$ echo $'name,naics_2017\n"test",\n"test2","100"' > fk_test.csv

$ dolt table import -u businesses fk_test.csv
@timsehn timsehn added the cli label Aug 30, 2022
@timsehn
Copy link
Sponsor Contributor

timsehn commented Aug 30, 2022

Better error message now:

test-fk-indexes $ dolt table import -u businesses fk_test.csv

A bad row was encountered while moving data.
Bad Row: [test,<nil>]
column name 'naics_2017' is non-nullable but attempted to set a value of null
These can be ignored using '--continue'

@timsehn timsehn closed this as completed Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants