Skip to content

Commit

Permalink
Merge pull request #618 from koordinates/mssql-fix
Browse files Browse the repository at this point in the history
Fix for #617 - large geometries breaks MSSQL WC
  • Loading branch information
olsen232 authored May 6, 2022
2 parents f4db98f + 64f795b commit 8a32688
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion kart/sqlalchemy/adapter/sqlserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Binary file added tests/data/large-geometry.tgz
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/test_working_copy_sqlserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8a32688

Please sign in to comment.