diff --git a/CHANGELOG.md b/CHANGELOG.md index fe0a35c8a..6d9b82652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ _When adding new entries to the changelog, please include issue/PR numbers where - Added support for `--output` option to `kart conflicts`. [#135](https://github.com/koordinates/kart/issues/135) - Bugfix: Better error message on using `kart conflicts -ogeojson` for `meta-item` conflicts. [#515](https://github.com/koordinates/kart/issues/515) - Removed the older `upgrade-to-tidy` and `upgrade-to-kart` features which were only relevant to Sno (predecessor of Kart). [[#585](https://github.com/koordinates/kart/issues/585]] -- Added support for `--decorate` and `--no-decorate` in `kart log`. [[#586](https://github.com/koordinates/kart/issues/586]] +- Added support for `--decorate` and `--no-decorate` in `kart log`. [#586](https://github.com/koordinates/kart/issues/586) +- Bugfix: Fixed a bug where creating a MSSQL working copy fails when there are large (~10KB) geometries. [#617](https://github.com/koordinates/kart/issues/617) ## 0.11.1 diff --git a/kart/sqlalchemy/adapter/sqlserver.py b/kart/sqlalchemy/adapter/sqlserver.py index 5388d89eb..c4c23e113 100644 --- a/kart/sqlalchemy/adapter/sqlserver.py +++ b/kart/sqlalchemy/adapter/sqlserver.py @@ -397,7 +397,8 @@ def sql_write(self, bindvalue): # POINT EMPTY is handled specially since it doesn't have a WKB value the SQL Server accepts. return sa.case( ( - bindvalue == sa.literal_column(self.EMPTY_POINT_WKB), + sa.cast(bindvalue, sa.VARBINARY) + == sa.literal_column(self.EMPTY_POINT_WKB), Function( quoted_name("geometry::STGeomFromText", False), "POINT EMPTY", diff --git a/tests/data/large-geometry.tgz b/tests/data/large-geometry.tgz new file mode 100644 index 000000000..4d6d34a48 Binary files /dev/null and b/tests/data/large-geometry.tgz differ diff --git a/tests/test_working_copy_sqlserver.py b/tests/test_working_copy_sqlserver.py index da484035d..6b214a9b0 100644 --- a/tests/test_working_copy_sqlserver.py +++ b/tests/test_working_copy_sqlserver.py @@ -655,3 +655,25 @@ def test_checkout_and_status_with_no_crs( ] ) assert r.exit_code == 0, r.stderr + + +def test_checkout_large_geometry( + new_sqlserver_db_schema, + data_archive, + tmp_path, + cli_runner, +): + repo_path = tmp_path / "repo" + repo_path.mkdir() + + with data_archive("large-geometry") as repo_path: + with new_sqlserver_db_schema() as (sqlserver_url, sqlserver_schema): + r = cli_runner.invoke(["create-workingcopy", sqlserver_url]) + r = cli_runner.invoke( + [ + "-C", + str(repo_path), + "status", + ] + ) + assert r.exit_code == 0, r.stderr