Bug 351487 - Invalid detection of primary key column on CSV import
Summary: Invalid detection of primary key column on CSV import
Status: CLOSED FIXED
Alias: None
Product: KEXI
Classification: Applications
Component: Migration/Import/Export (show other bugs)
Version: 2.9.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 2.9.7
Assignee: Jarosław Staniek
URL: https://phabricator.kde.org/D267
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-19 15:48 UTC by Albrecht Will
Modified: 2015-09-29 19:13 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.9.7
Sentry Crash Report:


Attachments
shows teh errormessage (24.32 KB, image/jpeg)
2015-08-19 15:49 UTC, Albrecht Will
Details
imported 2 rows without error (1.90 KB, text/csv)
2015-08-19 15:51 UTC, Albrecht Will
Details
csv-file wth 33 rows (10.93 KB, text/csv)
2015-08-19 15:52 UTC, Albrecht Will
Details
Minimal test for the bug (6 bytes, text/plain)
2015-08-24 12:30 UTC, Jarosław Staniek
Details
A screenshot showing preview of file #94114 (31.09 KB, image/jpeg)
2015-08-24 12:36 UTC, Jarosław Staniek
Details
After a fix: test .kexi file with imported all 3 test files (35.00 KB, application/octet-stream)
2015-08-24 16:19 UTC, Jarosław Staniek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Albrecht Will 2015-08-19 15:48:26 UTC
a speadsheet with over 450 rows ist exported to csv-format. During the import I get an error for a row.
So I tested two other spreadsheet versions. One with 3 rows - the error-row in the middle - will be imported without error. Then the version with 33 rows, it shows the earlier error again.
After submitting this text, I load up the last 2 csv-files and a picture from teh message.

Reproducible: Always
Comment 1 Albrecht Will 2015-08-19 15:49:21 UTC
Created attachment 94112 [details]
shows teh errormessage
Comment 2 Albrecht Will 2015-08-19 15:51:38 UTC
Created attachment 94113 [details]
imported 2 rows without error
Comment 3 Albrecht Will 2015-08-19 15:52:27 UTC
Created attachment 94114 [details]
csv-file wth 33 rows
Comment 4 Jarosław Staniek 2015-08-24 08:04:48 UTC
Albrecht,
Thanks for the detailed report.

Regarding the attached CSV 94113. It contains 3 rows of data and all 3 are imported (Kexi 2.9.7-pre, shall be same in this regard as 2.9.5). Checking another CSV.
Comment 5 Jarosław Staniek 2015-08-24 08:18:14 UTC
OK, row #22 failed to import. Looking there. The rest (31+the column names row) imported. Multiline rows valued imported too.
Comment 6 Jarosław Staniek 2015-08-24 12:30:55 UTC
Created attachment 94195 [details]
Minimal test for the bug

One-column and 2 rows of data shows the issue:
NULL
1

(attached)
For this file the column is auto-detected as having primary key. It should not be like that, the first record is NULL.
Comment 7 Jarosław Staniek 2015-08-24 12:36:14 UTC
Created attachment 94196 [details]
A screenshot showing preview of file #94114

A screenshot showing relevant part of preview of file #94114. Column 24, like the file #94195 has NULL values, and then integer value (=3). It shouldn't default to primary key, it shouldn't even be allowed for primary key. 

@Albrecht: The current workaround before the issue is fixed in Kexi, would be to scroll to that column and switch off the "Primary key" check box before importing.
Comment 8 Jarosław Staniek 2015-08-24 12:38:26 UTC
(altered the summary accordingly)
Comment 9 Jarosław Staniek 2015-08-24 16:19:57 UTC
Created attachment 94204 [details]
After a fix: test .kexi file with imported all 3 test files
Comment 10 Jarosław Staniek 2015-08-26 16:18:18 UTC
Git commit 00e2c35899826db373726b18e602c01fc0c8ef46 by Jaroslaw Staniek.
Committed on 26/08/2015 at 16:15.
Pushed by staniek into branch 'calligra/2.9'.

Kexi: Fix detection of primary key column on CSV import
FIXED-IN:2.9.7

Also:
* fix updates of primary key detection when value of 'Start at line' changes
* simplify some code

Test Plan:
Attached to https://bugs.kde.org/show_bug.cgi?id=351487:
* mussweg_1.csv - test passed
* mussweg_2.csv - test showing error in row #22, details: https://bugs.kde.org/show_bug.cgi?id=351487#c5
* simple-err.csv - minimal test showing the bug (PK is detected); after the fix PK should not be detected

Reviewers: piggz

Subscribers: Kexi-Devel-list

Differential Revision: https://phabricator.kde.org/D267

M  +34   -27   kexi/plugins/importexport/csv/kexicsvimportdialog.cpp
M  +3    -1    kexi/plugins/importexport/csv/kexicsvimportdialog.h

http://commits.kde.org/calligra/00e2c35899826db373726b18e602c01fc0c8ef46