Skip to content

Commit

Permalink
Merge pull request #900 from koordinates/global-mapper
Browse files Browse the repository at this point in the history
Fix for global-mapper incompatibility
  • Loading branch information
olsen232 committed Aug 17, 2023
2 parents 24fa122 + 76288b7 commit e4e3589
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _When adding new entries to the changelog, please include issue/PR numbers where
- Speed-up: greatly reduces the time taken to update the index file after checking out LFS tiles to the working copy. [#880](https://github.com/koordinates/kart/pull/880)
- Adds `--with-dataset-types` option to `kart data ls` command (and deprecates `kart data version`). [#892](https://github.com/koordinates/kart/issues/892)
- Use `journal_mode = WAL` in annotations.db sqlite database. [#898](https://github.com/koordinates/kart/pull/898)
- Slightly modifies the GPKG working copy format to avoid an incompatiblity with [Global Mapper](https://www.bluemarblegeo.com/global-mapper/). [#899](https://github.com/koordinates/kart/issues/899)

## 0.14.0

Expand Down
4 changes: 2 additions & 2 deletions kart/tabular/working_copy/gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ def create_triggers(self, sess, dataset):
CREATE TRIGGER IF NOT EXISTS {self._quoted_tracking_name('upd', dataset)}
AFTER UPDATE ON {table_identifier}
BEGIN
INSERT OR REPLACE INTO {self.KART_TRACK} (table_name, pk)
VALUES (:table_name1, NEW.{pk_column}), (:table_name2, OLD.{pk_column});
INSERT OR REPLACE INTO {self.KART_TRACK} (table_name, pk) VALUES (:table_name1, NEW.{pk_column});
INSERT OR REPLACE INTO {self.KART_TRACK} (table_name, pk) VALUES (:table_name2, OLD.{pk_column});
END;
""",
{"table_name1": dataset.table_name, "table_name2": dataset.table_name},
Expand Down
17 changes: 16 additions & 1 deletion tests/test_working_copy_gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ def test_checkout_with_no_crs(


def test_working_copy_progress_bar(cli_runner, data_working_copy, monkeypatch):
with data_working_copy("points") as repo_path:
with data_working_copy("points") as (repo_path, wc_path):
r = cli_runner.invoke(["create-workingcopy", "--delete-existing"])
assert r.exit_code == 0, r.stderr
progress_output = r.stderr.splitlines()
Expand All @@ -1225,3 +1225,18 @@ def test_working_copy_progress_bar(cli_runner, data_working_copy, monkeypatch):
r"nz_pa_points_topo_150k: 100%\|█+\| 2143/2143 \[[0-9:<]+, [0-9\.]+F/s\]",
progress_output[-1],
)


def test_global_mapper_compatibility(data_working_copy):
# See https://github.com/koordinates/kart/issues/899
with data_working_copy("points") as (repo_path, wc_path):
repo = KartRepo(repo_path)
table_wc = repo.working_copy.tabular
with table_wc.session() as sess:
r = sess.execute("SELECT sql FROM sqlite_schema;")
schemas = [row[0] for row in r if row[0]]
# Global Mapper does understand this SQL snippet: VALUES (...) and we expect some in the triggers
assert any(re.search(r"VALUES\s*\([^();]*\)", s) for s in schemas)
# But it does not understand this SQL snippet: VALUES (...), (...)
# Make sure that doesn't occur in our GPKG working copy.
assert all(not re.search(r"VALUES\s*\([^();]*\)\s*,", s) for s in schemas)

0 comments on commit e4e3589

Please sign in to comment.