Skip to content

Commit

Permalink
breaking: fix geoJson parameter (#318)
Browse files Browse the repository at this point in the history
* breaking: fix `geoJson` parameter

* update `geo_json` docstring
  • Loading branch information
aMahanna authored Feb 2, 2024
1 parent 97bf6d8 commit 92b5f94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions arango/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -1385,8 +1385,10 @@ 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. 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
:param in_background: Do not hold the collection lock.
Expand All @@ -1400,8 +1402,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:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ 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 = {
"sparse": True,
"type": "geo",
"fields": ["attr1"],
"unique": False,
"geo_json": False,
"geo_json": True,
"name": "geo_index",
}
for key, value in expected_index.items():
Expand All @@ -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,
Expand Down

0 comments on commit 92b5f94

Please sign in to comment.