fix: normalize qgis_projects blob types around commit for QGIS compatibility#124
Draft
idshklein wants to merge 2 commits intokoordinates:mainfrom
Draft
fix: normalize qgis_projects blob types around commit for QGIS compatibility#124idshklein wants to merge 2 commits intokoordinates:mainfrom
idshklein wants to merge 2 commits intokoordinates:mainfrom
Conversation
…ompatibility QGIS stores qgis_projects.content as text-encoded hex and qgis_projects.metadata as plain text, but Kart's internal schema declares both columns as blob. When a user tries to commit, Kart raises: Schema violation - values do not match schema This fix wraps Repository.commit() with two helpers: _normalizeQgisProjectsForKart – converts text → blob/unhex just before kart commit _restoreQgisProjectsForQgis – converts blob → text/hex in a finally block so that (a) the commit succeeds and (b) QGIS can still open the project from the working-copy GeoPackage without any user-visible disruption. The normalization is only applied when the working copy is a GeoPackage (not PostgreSQL) and only when a qgis_projects table is present.
…re loop feature.fields().names() includes auto_int_pk (Kart's surrogate primary key added to GeoPackage working copies) but the diff JSON props only contains the actual dataset columns. Iterating all field names and blindly indexing into props crashes with KeyError: 'auto_int_pk'. The idField value is already set explicitly on the line that follows the loop, so missing fields can safely be skipped with a guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a QGIS project is saved into a Kart-managed GeoPackage, QGIS writes qgis_projects.content as a text-encoded hex string and qgis_projects.metadata as plain text.
Kart's internal schema for qgis_projects declares both columns as �lob. When a user attempts to commit via the plugin, kart commit fails with:
\
Schema violation - values do not match schema
\\
Conversely, if the rows are converted to true blobs before the commit, QGIS can no longer open the project from the working-copy GeoPackage (\Unable to unzip file).
Fix
Three methods are added to Repository in kartapi.py:
The round-trip is transparent to the user: the GPKG is left in the same QGIS-readable state it was in before the commit.
Scope
Testing
Manually verified end-to-end on Windows 11 / QGIS 3.38 / Kart 0.14: