From 81046462e62f76c4fbd0fd3763d14ff1996ec4b7 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Fri, 19 Jan 2024 12:12:38 -0500 Subject: [PATCH 1/2] breaking: fix `geoJson` parameter --- arango/collection.py | 10 +++++----- tests/test_index.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arango/collection.py b/arango/collection.py index 930ef771..7557a4ef 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1373,7 +1373,7 @@ def add_skiplist_index( def add_geo_index( self, fields: Fields, - ordered: Optional[bool] = None, + geo_json: Optional[bool] = None, name: Optional[str] = None, in_background: Optional[bool] = None, legacyPolygons: Optional[bool] = False, @@ -1385,8 +1385,8 @@ def add_geo_index( with at least two floats. Documents with missing fields or invalid values are excluded. :type fields: str | [str] - :param ordered: Whether the order is longitude, then latitude. - :type ordered: bool | None + :param geo_json: Whether to use GeoJSON data-format or not. + :type geo_json: bool | None :param name: Optional name for the index. :type name: str | None :param in_background: Do not hold the collection lock. @@ -1400,8 +1400,8 @@ def add_geo_index( """ data: Json = {"type": "geo", "fields": fields} - if ordered is not None: - data["geoJson"] = ordered + if geo_json is not None: + data["geoJson"] = geo_json if name is not None: data["name"] = name if in_background is not None: diff --git a/tests/test_index.py b/tests/test_index.py index dbf235fa..5b5fcce9 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -107,7 +107,7 @@ def test_add_skiplist_index(icol): def test_add_geo_index(icol): # Test add geo index with one attribute result = icol.add_geo_index( - fields=["attr1"], ordered=False, name="geo_index", in_background=True + fields=["attr1"], geo_json=True, name="geo_index", in_background=True ) expected_index = { @@ -115,7 +115,7 @@ def test_add_geo_index(icol): "type": "geo", "fields": ["attr1"], "unique": False, - "geo_json": False, + "geo_json": True, "name": "geo_index", } for key, value in expected_index.items(): @@ -126,7 +126,7 @@ def test_add_geo_index(icol): # Test add geo index with two attributes result = icol.add_geo_index( fields=["attr1", "attr2"], - ordered=False, + geo_json=False, ) expected_index = { "sparse": True, From 5b0d0aec9555231c5a8428fa6cac5fbc69209d88 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Tue, 30 Jan 2024 11:03:33 -0500 Subject: [PATCH 2/2] update `geo_json` docstring --- arango/collection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arango/collection.py b/arango/collection.py index 7557a4ef..38d8512b 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1385,7 +1385,9 @@ def add_geo_index( with at least two floats. Documents with missing fields or invalid values are excluded. :type fields: str | [str] - :param geo_json: Whether to use GeoJSON data-format or not. + :param geo_json: Whether to use GeoJSON data-format or not. This + parameter has been renamed from `ordered`. See Github Issue + #234 for more details. :type geo_json: bool | None :param name: Optional name for the index. :type name: str | None