koordinates / kart

Distributed version-control for geospatial and tabular data
https://kartproject.org
Other
522 stars 41 forks source link

Kart GPKG working copy not compatible with GlobalMapper #899

Closed olsen232 closed 1 year ago

olsen232 commented 1 year ago

GlobalMapper fails to open Kart GPKG working copies, with an malformed-database-schema error

After some digging, turns out GlobalMapper doesn't like this trigger:

CREATE TRIGGER _mytable_upd
   AFTER UPDATE ON mytable
BEGIN
    INSERT OR REPLACE INTO gpkg_kart_track (table_name, pk)
    VALUES ('mytable', NEW.fid), ('mytable', OLD.fid);
END;

Specifically it doesn't understand this form of INSERT: INSERT [OR REPLACE] INTO <into> VALUES <row1>, <row2>;

If one of the rows-to-insert the trigger is removed, GlobalMapper is happy. Presumably GlobalMapper uses a very old sqlite version that doesn't understand such things.

As a workaround, Kart could create the update trigger with two insert statements that insert one row each, instead of one trigger that inserts two rows. This has no real downsides (slightly less efficient) so we may as well.

Version Info

rcoup commented 1 year ago

Presumably GlobalMapper uses a very old sqlite version that doesn't understand such things.

Very old being at least 10 years:

SQLite Release 3.7.11 On 2012-03-20

  1. Enhance the INSERT syntax to allow multiple rows to be inserted via the VALUES clause.
olsen232 commented 1 year ago

This is fixed in release 0.14.1 - if you are affected by this issue, recreate your Kart working copy using Kart 0.14.1 ie kart create-workingcopy --delete-existing