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

Kart should check PK fields are actually unique #879

Closed
craigds opened this issue Jun 22, 2023 · 1 comment
Closed

Kart should check PK fields are actually unique #879

craigds opened this issue Jun 22, 2023 · 1 comment

Comments

@craigds
Copy link
Member

craigds commented Jun 22, 2023

Describe the bug
If you import a tabular dataset with the --primary-key option, it's possible to use a field that isn't actually unique.

Kart doesn't check, and any duplicate rows silently overwrite each other during import.

To Reproduce

  • sqlite3 bad-pks.sqlite
  • create table mydataset (badpk integer, sometext text);
    insert into mydataset (badpk, sometext) values (1, 'text1');
    insert into mydataset (badpk, sometext) values (1, 'text2');
    
  • kart init myrepo ; cd myrepo
  • kart import --primary-key=badpk OGR:../bad-pks.sqlite
  • kart show -- mydataset:feature

Expected behaviour

An error should be raised since the badpk field has two duplicate values

Output

The dataset is imported and only one of the features survives

$ kart show -- mydataset:feature
commit d2439097269d5dccd73aaec4d0fd388e6e9aa669
Author: Craig de Stigter <craig@destigter.nz>
Date:   Fri Jun 23 10:21:11 2023 +1200

    Import from bad-pks.sqlite:mydataset to mydataset/

+++ mydataset:feature:1
+                                    badpk = 1
+                                 sometext = text2

**Version Info **

  • OS: macOS 13.4
  • Version: 0.14.0rc2
@hamishcampbell
Copy link
Member

Duplicate of #307 ?

@craigds craigds closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
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

2 participants