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

Enforce uniqueness of primary key fields at import/commit time #307

Open
olsen232 opened this issue Nov 15, 2020 · 3 comments
Open

Enforce uniqueness of primary key fields at import/commit time #307

olsen232 opened this issue Nov 15, 2020 · 3 comments

Comments

@olsen232
Copy link
Collaborator

olsen232 commented Nov 15, 2020

GPKG only supports integer primary keys, whereas a Kart dataset already supports string primary keys.
We should be able to adapt one to the other in some way so that you can have a GPKG working copy that is backed by a dataset with string keys - perhaps a dummy integer primary key will be added, and the original string primary key will present in the working copy but not in the primary key column.

@olsen232 olsen232 self-assigned this Nov 15, 2020
@olsen232 olsen232 changed the title Support for GPKG + alphanumeric primary keys Support for GPKG + string primary keys Nov 24, 2020
@olsen232
Copy link
Collaborator Author

olsen232 commented Nov 25, 2020

Done except there is one more edge case that hasn't been dealt with and could do with some more work:

  • what happens if you drop a column in QGIS, which blows away any unique constraints, then start adding non-unique values in the string-pk column?

@olsen232 olsen232 changed the title Support for GPKG + string primary keys Handle edge cases: GPKG + string primary keys Nov 29, 2020
@olsen232 olsen232 removed their assignment Jul 7, 2021
@craigds
Copy link
Member

craigds commented Feb 20, 2022

I'd suggest we add some code to check for dupe PKs at commit time, in the case that the WC isn't enforcing that for us. Throwing a useful error seems like it would adequately fix this problem, something like

mydatasetname: The value 'abc-123' in the "pk" column is not unique. Please fix this and try committing again.

@craigds craigds changed the title Handle edge cases: GPKG + string primary keys Enforce uniqueness of primary key fields at commit time Feb 20, 2022
@craigds
Copy link
Member

craigds commented Jun 27, 2023

to add to this, even if the WC or import source does normally enforce uniqueness of PKs, you can bypass that by doing kart import --primary-key customfield ..., and kart should check that field for uniqueness.

@craigds craigds changed the title Enforce uniqueness of primary key fields at commit time Enforce uniqueness of primary key fields at import/commit time 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