Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking: fix geoJson parameter #318

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading