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

Importing NULL values errors even when default is provided #8387

Open
max-hoffman opened this issue Sep 25, 2024 · 0 comments
Open

Importing NULL values errors even when default is provided #8387

max-hoffman opened this issue Sep 25, 2024 · 0 comments
Labels

Comments

@max-hoffman
Copy link
Contributor

Importing into a field with a default value for nulls errors for null values.

An error occurred while moving data
cause: column name 'cl_sortkey_prefix' is non-nullable but attempted to set a value of null
       A bad row was encountered inserting into table categorylinks (on line 9):
       	cl_from: 13305
       	cl_to: Linguistic_morphology
       	cl_sortkey: MORPHOPHONOLOGY
       	cl_sortkey_prefix: <nil>
       	cl_timestamp: 2024-03-12 02:10:51
       	cl_collation: uppercase
       	cl_type: page

#!/bin/bash

rm -rf tmp1
mkdir tmp1
cd tmp1
dolt init

dolt sql <<EOF
CREATE TABLE categorylinks (
cl_from int unsigned NOT NULL DEFAULT '0',
cl_to varbinary(255) NOT NULL DEFAULT '',
cl_sortkey varbinary(230) NOT NULL DEFAULT '',
cl_sortkey_prefix varbinary(255) NOT NULL DEFAULT '',
cl_timestamp timestamp NOT NULL,
cl_collation varbinary(32) NOT NULL DEFAULT '',
cl_type enum('page','subcat','file') NOT NULL DEFAULT '1',
PRIMARY KEY (cl_from,cl_to),
KEY cl_collation_ext (cl_collation,cl_to,cl_type,cl_from),
KEY cl_sortkey (cl_to,cl_type,cl_sortkey,cl_from),
KEY cl_timestamp (cl_to,cl_timestamp)
);
EOF

cat < test1.csv
cl_from,cl_to,cl_sortkey,cl_sortkey_prefix,cl_timestamp,cl_collation,cl_type
cl_from,cl_to,cl_sortkey,cl_sortkey_prefix,cl_timestamp,cl_collation,cl_type
13303,Communes_of_Tarn-et-Garonne,MONTAUBAN,,2024-03-12 02:10:49,uppercase,page
13303,Pages_with_broken_file_links,MONTAUBAN,,2024-03-12 02:10:49,uppercase,page
13303,Prefectures_in_France,MONTAUBAN,,2024-03-12 02:10:49,uppercase,page
13303,Quercy,MONTAUBAN,,2024-03-12 02:10:49,uppercase,page
13304,Pages_with_broken_file_links,RAIL TRANSPORT MODELLING,,2024-03-12 02:10:50,uppercase,page
13304,Rail_transport_modelling, RAIL TRANSPORT MODELLING, ,2024-03-12 02:10:50,uppercase,page
13305,Linguistic_morphology,MORPHOPHONOLOGY,,2024-03-12 02:10:51,uppercase,page
13305,Morphophonology, MORPHOPHONOLOGY, ,2024-03-12 02:10:51,uppercase,page
13305,Orthography,MORPHOPHONOLOGY,,2024-03-12 02:10:51,uppercase,page
13305,Phonology,MORPHOPHONOLOGY,,2024-03-12 02:10:51,uppercase,page
13306,Glass_applications,MIRROR,,2024-03-12 02:10:52,uppercase,page
EOF

dolt table import -u categorylinks test1.csv


Replacing nulls with empty strings `''` fixes:

cl_from,cl_to,cl_sortkey,cl_sortkey_prefix,cl_timestamp,cl_collation,cl_type
13303,Communes_of_Tarn-et-Garonne,MONTAUBAN,'',2024-03-12 02:10:49,uppercase,page
13303,Pages_with_broken_file_links,MONTAUBAN,'',2024-03-12 02:10:49,uppercase,page
13303,Prefectures_in_France,MONTAUBAN,'',2024-03-12 02:10:49,uppercase,page
13303,Quercy,MONTAUBAN,'',2024-03-12 02:10:49,uppercase,page
13304,Miniature_railways, RAIL TRANSPORT MODELLING,'',2024-03-12 02:10:50,uppercase,page
13304,Pages_with_broken_file_links,RAIL TRANSPORT MODELLING,'',2024-03-12 02:10:50,uppercase,page
13304,Rail_transport_modelling, RAIL TRANSPORT MODELLING,'',2024-03-12 02:10:50,uppercase,page
13305,Linguistic_morphology,MORPHOPHONOLOGY,'',2024-03-12 02:10:51,uppercase,page
13305,Morphophonology, MORPHOPHONOLOGY,'',2024-03-12 02:10:51,uppercase,page
13305,Orthography,MORPHOPHONOLOGY,'',2024-03-12 02:10:51,uppercase,page
13305,Phonology,MORPHOPHONOLOGY,'',2024-03-12 02:10:51,uppercase,page
13306,Glass_applications,MIRROR,'',2024-03-12 02:10:52,uppercase,page

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

1 participant