From 04a3ad099f9a9b482f799e185ab4f343b4335636 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Fri, 2 Feb 2024 16:35:48 -0500 Subject: [PATCH 01/14] make `add_index` public | initial commit --- README.md | 2 +- arango/collection.py | 126 ++++++++++-------------------------- docs/indexes.rst | 26 +++++--- docs/overview.rst | 2 +- tests/conftest.py | 10 +-- tests/test_collection.py | 3 +- tests/test_document.py | 3 +- tests/test_index.py | 136 +++++++++++++++++++++++++-------------- 8 files changed, 149 insertions(+), 159 deletions(-) diff --git a/README.md b/README.md index ac3bf680..ed9c8466 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ db = client.db("test", username="root", password="passwd") students = db.create_collection("students") # Add a hash index to the collection. -students.add_hash_index(fields=["name"], unique=True) +students.add_index({'type': 'hash', 'fields': ['name'], 'unique': True}) # Insert new documents into the collection. students.insert({"name": "jane", "age": 39}) diff --git a/arango/collection.py b/arango/collection.py index c6ea4184..31d269d3 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -2,6 +2,7 @@ from numbers import Number from typing import List, Optional, Sequence, Tuple, Union +from warnings import warn from arango.api import ApiGroup from arango.connection import Connection @@ -1259,10 +1260,11 @@ def response_handler(resp: Response) -> Json: return self._execute(request, response_handler) - def _add_index(self, data: Json) -> Result[Json]: - """Helper method for creating a new index. + def add_index(self, data: Json) -> Result[Json]: + """Create an index. - :param data: Index data. + :param data: Index data. Must contain a "type" field + with the index type. :type data: dict :return: New index details. :rtype: dict @@ -1311,6 +1313,9 @@ def add_hash_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ + m = "add_hash_index is deprecated. Using add_index with {'type': 'hash'} instead." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + data: Json = {"type": "hash", "fields": fields} if unique is not None: @@ -1324,7 +1329,7 @@ def add_hash_index( if in_background is not None: data["inBackground"] = in_background - return self._add_index(data) + return self.add_index(data) def add_skiplist_index( self, @@ -1355,6 +1360,9 @@ def add_skiplist_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ + m = "add_skiplist_index is deprecated. Using add_index with {'type': 'skiplist'} instead." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + data: Json = {"type": "skiplist", "fields": fields} if unique is not None: @@ -1368,7 +1376,7 @@ def add_skiplist_index( if in_background is not None: data["inBackground"] = in_background - return self._add_index(data) + return self.add_index(data) def add_geo_index( self, @@ -1400,6 +1408,9 @@ def add_geo_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ + m = "add_geo_index is deprecated. Using add_index with {'type': 'geo'} instead." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + data: Json = {"type": "geo", "fields": fields} if geo_json is not None: @@ -1411,7 +1422,7 @@ def add_geo_index( if legacyPolygons is not None: data["legacyPolygons"] = legacyPolygons - return self._add_index(data) + return self.add_index(data) def add_fulltext_index( self, @@ -1436,6 +1447,9 @@ def add_fulltext_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ + m = "add_fulltext_index is deprecated. Using add_index with {'type': 'fulltext'} instead." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + data: Json = {"type": "fulltext", "fields": fields} if min_length is not None: @@ -1445,7 +1459,7 @@ def add_fulltext_index( if in_background is not None: data["inBackground"] = in_background - return self._add_index(data) + return self.add_index(data) def add_persistent_index( self, @@ -1488,6 +1502,9 @@ def add_persistent_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ + m = "add_persistent_index is deprecated. Using add_index with {'type': 'persistent'} instead." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + data: Json = {"type": "persistent", "fields": fields} if unique is not None: @@ -1503,7 +1520,7 @@ def add_persistent_index( if cacheEnabled is not None: data["cacheEnabled"] = cacheEnabled - return self._add_index(data) + return self.add_index(data) def add_ttl_index( self, @@ -1526,6 +1543,9 @@ def add_ttl_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ + m = "add_ttl_index is deprecated. Using add_index with {'type': 'ttl'} instead." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + data: Json = {"type": "ttl", "fields": fields, "expireAfter": expiry_time} if name is not None: @@ -1533,7 +1553,7 @@ def add_ttl_index( if in_background is not None: data["inBackground"] = in_background - return self._add_index(data) + return self.add_index(data) def add_inverted_index( self, @@ -1588,6 +1608,9 @@ def add_inverted_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ + m = "add_inverted_index is deprecated. Using add_index with {'type': 'inverted'} instead." # noqa: E501 + warn(m, DeprecationWarning, stacklevel=2) + data: Json = {"type": "inverted", "fields": fields} if name is not None: @@ -1617,90 +1640,7 @@ def add_inverted_index( if cache is not None: data["cache"] = cache - return self._add_index(data) - - def add_zkd_index( - self, - fields: Sequence[str], - field_value_types: str = "double", - name: Optional[str] = None, - unique: Optional[bool] = None, - in_background: Optional[bool] = None, - ) -> Result[Json]: - """Create a new ZKD Index. - - :param fields: Document fields to index. Unlike for other indexes the - order of the fields does not matter. - :type fields: Sequence[str] - :param field_value_types: The type of the field values. The only allowed - value is "double" at the moment. Defaults to "double". - :type field_value_types: str - :param name: Optional name for the index. - :type name: str | None - :param unique: Whether the index is unique. - :type unique: bool | None - :param in_background: Do not hold the collection lock. - :type in_background: bool | None - :return: New index details. - :rtype: dict - :raise arango.exceptions.IndexCreateError: If create fails. - """ - data: Json = { - "type": "zkd", - "fields": fields, - "fieldValueTypes": field_value_types, - } - - if unique is not None: - data["unique"] = unique - if name is not None: - data["name"] = name - if in_background is not None: - data["inBackground"] = in_background - - return self._add_index(data) - - def add_mdi_index( - self, - fields: Sequence[str], - field_value_types: str = "double", - name: Optional[str] = None, - unique: Optional[bool] = None, - in_background: Optional[bool] = None, - ) -> Result[Json]: - """Create a new MDI index, previously known as ZKD index. This method - is only usable with ArangoDB 3.12 and later. - - :param fields: Document fields to index. Unlike for other indexes the - order of the fields does not matter. - :type fields: Sequence[str] - :param field_value_types: The type of the field values. The only allowed - value is "double" at the moment. Defaults to "double". - :type field_value_types: str - :param name: Optional name for the index. - :type name: str | None - :param unique: Whether the index is unique. - :type unique: bool | None - :param in_background: Do not hold the collection lock. - :type in_background: bool | None - :return: New index details. - :rtype: dict - :raise arango.exceptions.IndexCreateError: If create fails. - """ - data: Json = { - "type": "mdi", - "fields": fields, - "fieldValueTypes": field_value_types, - } - - if unique is not None: - data["unique"] = unique - if name is not None: - data["name"] = name - if in_background is not None: - data["inBackground"] = in_background - - return self._add_index(data) + return self.add_index(data) def delete_index(self, index_id: str, ignore_missing: bool = False) -> Result[bool]: """Delete an index. diff --git a/docs/indexes.rst b/docs/indexes.rst index 01750146..b553d6a9 100644 --- a/docs/indexes.rst +++ b/docs/indexes.rst @@ -28,26 +28,36 @@ on fields ``_from`` and ``_to``. For more information on indexes, refer to cities.indexes() # Add a new hash index on document fields "continent" and "country". - index = cities.add_hash_index(fields=['continent', 'country'], unique=True) + hash_index = {'type': 'hash', 'fields': ['continent', 'country'], 'unique': True} + index = cities.add_index(hash_index) # Add new fulltext indexes on fields "continent" and "country". - index = cities.add_fulltext_index(fields=['continent']) - index = cities.add_fulltext_index(fields=['country']) + index = cities.add_index({'type': 'fulltext', 'fields': ['continent']}) + index = cities.add_index({'type': 'fulltext', 'fields': ['country']}) # Add a new skiplist index on field 'population'. - index = cities.add_skiplist_index(fields=['population'], sparse=False) + skiplist_index = {'type': 'skiplist', 'fields': ['population'], 'sparse': False} + index = cities.add_index(skiplist_index) # Add a new geo-spatial index on field 'coordinates'. - index = cities.add_geo_index(fields=['coordinates']) + geo_index = {'type': 'geo', 'fields': ['coordinates']} + index = cities.add_index(geo_index) # Add a new persistent index on field 'currency'. - index = cities.add_persistent_index(fields=['currency'], sparse=True) + persistent_index = {'type': 'persistent', 'fields': ['currency'], 'sparse': True} + index = cities.add_index(persistent_index) # Add a new TTL (time-to-live) index on field 'currency'. - index = cities.add_ttl_index(fields=['currency'], expiry_time=200) + ttl_index = {'type': 'ttl', 'fields': ['currency'], 'expireAfter': 200} + index = cities.add_index(ttl_index) + + # Add MDI (multi-dimensional) index on field 'x' and 'y'. + mdi_index = {'type': 'mdi', 'fields': ['x', 'y'], 'field_value_types': ['double']} + index = cities.add_index(mdi_index) # Indexes may be added with a name that can be referred to in AQL queries. - index = cities.add_hash_index(fields=['country'], name='my_hash_index') + hash_index = {'type': 'hash', 'fields': ['country'], 'unique': True, 'name': 'my_hash_index'} + index = cities.add_index(hash_index) # Delete the last index from the collection. cities.delete_index(index['id']) diff --git a/docs/overview.rst b/docs/overview.rst index 76ff4155..b31effe0 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -30,7 +30,7 @@ Here is an example showing how **python-arango** client can be used: students = db.create_collection('students') # Add a hash index to the collection. - students.add_hash_index(fields=['name'], unique=False) + students.add_index({'type': 'hash', 'fields': ['name'], 'unique': True}) # Truncate the collection. students.truncate() diff --git a/tests/conftest.py b/tests/conftest.py index 184269d7..a0d2a878 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -51,7 +51,7 @@ class GlobalData: def pytest_addoption(parser): parser.addoption("--host", action="store", default="127.0.0.1") parser.addoption("--port", action="append", default=None) - parser.addoption("--passwd", action="store", default="passwd") + parser.addoption("--passwd", action="store", default="") parser.addoption("--complete", action="store_true") parser.addoption("--cluster", action="store_true") parser.addoption("--replication", action="store_true") @@ -78,7 +78,7 @@ def pytest_configure(config): name="_system", username="root", password=config.getoption("passwd"), - superuser_token=generate_jwt(secret), + # superuser_token=generate_jwt(secret), verify=True, ) @@ -106,9 +106,9 @@ def pytest_configure(config): col_name = generate_col_name() tst_col = tst_db.create_collection(col_name, edge=False) - tst_col.add_skiplist_index(["val"]) - tst_col.add_fulltext_index(["text"]) - geo_index = tst_col.add_geo_index(["loc"]) + tst_col.add_index({"type": "skiplist", "fields": ["val"]}) + tst_col.add_index({"type": "fulltext", "fields": ["text"]}) + geo_index = tst_col.add_index({"type": "geo", "fields": ["loc"]}) # Create a legacy edge collection for testing. icol_name = generate_col_name() diff --git a/tests/test_collection.py b/tests/test_collection.py index a2d07587..08ae9c5d 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -362,7 +362,8 @@ def create_and_delete_collection(db, name): assert col.name == name assert db.has_collection(name) is True - index_id = col.add_hash_index(fields=["foo"])["name"] + hash_index = {"type": "hash", "fields": ["foo"]} + index_id = col.add_index(hash_index)["name"] assert index_id == col.indexes()[-1]["name"] assert col.delete_index(index_id) is True diff --git a/tests/test_document.py b/tests/test_document.py index a4127a27..c826a7f8 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -1463,7 +1463,8 @@ def test_document_find_in_box(db, col, bad_col, geo, cluster): ) # Test find_in_box with non-geo index - non_geo = col.add_hash_index(fields=["loc"]) + hash_index = {"type": "hash", "fields": ["loc"]} + non_geo = col.add_index(hash_index) with assert_raises(ValueError) as err: col.find_in_box( latitude1=0, diff --git a/tests/test_index.py b/tests/test_index.py index 375ff000..ec314c37 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -50,19 +50,22 @@ def test_add_hash_index(icol): icol = icol fields = ["attr1", "attr2"] - result = icol.add_hash_index( - fields=fields, - unique=True, - sparse=True, - deduplicate=True, - name="hash_index", - in_background=False, + result = icol.add_index( + { + "type": "hash", + "fields": fields, + "unique": True, + "sparse": True, + "deduplicate": True, + "name": "hash_index", + "in_background": False, + } ) expected_index = { "sparse": True, "type": "hash", - "fields": ["attr1", "attr2"], + "fields": fields, "unique": True, "deduplicate": True, "name": "hash_index", @@ -78,13 +81,15 @@ def test_add_hash_index(icol): def test_add_skiplist_index(icol): fields = ["attr1", "attr2"] - result = icol.add_skiplist_index( - fields=fields, - unique=True, - sparse=True, - deduplicate=True, - name="skiplist_index", - in_background=False, + result = icol.add_index( + { + "fields": fields, + "unique": True, + "sparse": True, + "deduplicate": True, + "name": "skiplist_index", + "in_background": False, + } ) expected_index = { @@ -106,8 +111,14 @@ 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"], geo_json=True, name="geo_index", in_background=True + result = icol.add_index( + { + "type": "geo", + "fields": ["attr1"], + "geo_json": True, + "name": "geo_index", + "in_background": True, + } ) expected_index = { @@ -119,14 +130,17 @@ def test_add_geo_index(icol): "name": "geo_index", } for key, value in expected_index.items(): - assert result[key] == value + assert result[key] == value, (key, value, result[key]) assert result["id"] in extract("id", icol.indexes()) # Test add geo index with two attributes - result = icol.add_geo_index( - fields=["attr1", "attr2"], - geo_json=False, + result = icol.add_index( + { + "type": "geo", + "fields": ["attr1", "attr2"], + "geo_json": False, + } ) expected_index = { "sparse": True, @@ -141,7 +155,7 @@ def test_add_geo_index(icol): # Test add geo index with more than two attributes (should fail) with assert_raises(IndexCreateError) as err: - icol.add_geo_index(fields=["attr1", "attr2", "attr3"]) + icol.add_index({"type": "geo", "fields": ["attr1", "attr2", "attr3"]}) assert err.value.error_code == 10 # Clean up the index @@ -150,8 +164,14 @@ def test_add_geo_index(icol): def test_add_fulltext_index(icol): # Test add fulltext index with one attributes - result = icol.add_fulltext_index( - fields=["attr1"], min_length=10, name="fulltext_index", in_background=True + result = icol.add_index( + { + "type": "fulltext", + "fields": ["attr1"], + "min_length": 10, + "name": "fulltext_index", + "in_background": True, + } ) expected_index = { "sparse": True, @@ -168,7 +188,7 @@ def test_add_fulltext_index(icol): # Test add fulltext index with two attributes (should fail) with assert_raises(IndexCreateError) as err: - icol.add_fulltext_index(fields=["attr1", "attr2"]) + icol.add_index({"type": "fulltext", "fields": ["attr1", "attr2"]}) assert err.value.error_code == 10 # Clean up the index @@ -177,12 +197,15 @@ def test_add_fulltext_index(icol): def test_add_persistent_index(icol): # Test add persistent index with two attributes - result = icol.add_persistent_index( - fields=["attr1", "attr2"], - unique=True, - sparse=True, - name="persistent_index", - in_background=True, + result = icol.add_index( + { + "type": "persistent", + "fields": ["attr1", "attr2"], + "unique": True, + "sparse": True, + "name": "persistent_index", + "in_background": True, + } ) expected_index = { "sparse": True, @@ -202,8 +225,14 @@ def test_add_persistent_index(icol): def test_add_ttl_index(icol): # Test add persistent index with two attributes - result = icol.add_ttl_index( - fields=["attr1"], expiry_time=1000, name="ttl_index", in_background=True + result = icol.add_index( + { + "type": "ttl", + "fields": ["attr1"], + "expiry_time": 1000, + "name": "ttl_index", + "in_background": True, + } ) expected_index = { "type": "ttl", @@ -239,7 +268,7 @@ def test_add_inverted_index(icol, enterprise, db_version): parameters["primaryKeyCache"] = True expected_keys.extend(["cache", "primaryKeyCache"]) - result = icol.add_inverted_index(**parameters) + result = icol.add_index({"type": "inverted", **parameters}) assert result["id"] in extract("id", icol.indexes()) for key in expected_keys: @@ -249,12 +278,15 @@ def test_add_inverted_index(icol, enterprise, db_version): def test_add_zkd_index(icol, db_version): - result = icol.add_zkd_index( - name="zkd_index", - fields=["x", "y", "z"], - field_value_types="double", - in_background=False, - unique=False, + result = icol.add_index( + { + "type": "zkd", + "fields": ["x", "y", "z"], + "field_value_types": "double", + "name": "zkd_index", + "in_background": False, + "unique": False, + } ) expected_index = { @@ -281,12 +313,15 @@ def test_add_mdi_index(icol, db_version): if db_version < version.parse("3.12.0"): pytest.skip("MDI indexes are usable with 3.12+ only") - result = icol.add_mdi_index( - name="mdi_index", - fields=["x", "y", "z"], - field_value_types="double", - in_background=False, - unique=True, + result = icol.add_index( + { + "type": "mdi", + "fields": ["x", "y", "z"], + "field_value_types": "double", + "name": "mdi_index", + "in_background": False, + "unique": True, + } ) expected_index = { @@ -311,9 +346,12 @@ def test_add_mdi_index(icol, db_version): def test_delete_index(icol, bad_col): old_indexes = set(extract("id", icol.indexes())) - icol.add_hash_index(["attr3", "attr4"], unique=True) - icol.add_skiplist_index(["attr3", "attr4"], unique=True) - icol.add_fulltext_index(fields=["attr3"], min_length=10) + hash_index = {"type": "hash", "fields": ["attr1", "attr2"], "unique": True} + icol.add_index(hash_index) + skiplist_Index = {"type": "skiplist", "fields": ["attr3", "attr4"], "unique": True} + icol.add_index(skiplist_Index) + fulltext_index = {"type": "fulltext", "fields": ["attr5"], "min_length": 10} + icol.add_index(fulltext_index) new_indexes = set(extract("id", icol.indexes())) assert new_indexes.issuperset(old_indexes) From 41818de52642312805737455327965783b3772b5 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Fri, 2 Feb 2024 16:45:28 -0500 Subject: [PATCH 02/14] fix `conftest` --- tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a0d2a878..ee5a0cd3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -51,7 +51,7 @@ class GlobalData: def pytest_addoption(parser): parser.addoption("--host", action="store", default="127.0.0.1") parser.addoption("--port", action="append", default=None) - parser.addoption("--passwd", action="store", default="") + parser.addoption("--passwd", action="store", default="passwd") parser.addoption("--complete", action="store_true") parser.addoption("--cluster", action="store_true") parser.addoption("--replication", action="store_true") @@ -78,7 +78,7 @@ def pytest_configure(config): name="_system", username="root", password=config.getoption("passwd"), - # superuser_token=generate_jwt(secret), + superuser_token=generate_jwt(secret), verify=True, ) From 313aa16f0f08b5fbedb0cdccfb2d40b26451e671 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 19:32:15 +0300 Subject: [PATCH 03/14] Changed maintainer email --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index dee5fe8b..9f792f0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ description = "Python Driver for ArangoDB" authors = [ {name= "Joohwan Oh", email = "joohwan.oh@outlook.com" }] maintainers = [ {name = "Joohwan Oh", email = "joohwan.oh@outlook.com"}, - {name = "Alexandru Petenchea", email = "alexandru.petenchea@arangodb.com"}, + {name = "Alexandru Petenchea", email = "alex.petenchea@gmail.com"}, {name = "Anthony Mahanna", email = "anthony.mahanna@arangodb.com"} ] keywords = ["arangodb", "python", "driver"] From 261874c7c82a94c8d9e248e2f452ada90746480e Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 20:17:07 +0300 Subject: [PATCH 04/14] Fixing up after the merge --- arango/collection.py | 65 +++++++++++++++++++++++++++++++++++----- tests/test_collection.py | 4 +-- tests/test_document.py | 4 +-- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/arango/collection.py b/arango/collection.py index 31d269d3..0ec3c996 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1075,7 +1075,7 @@ def build_coord_str_from_index(index: Json) -> str: FILTER GEO_CONTAINS(rect, {coord_str}) LIMIT {skip_val}, {limit_val} RETURN doc - """ + """ # noqa: E201 E202 bind_vars = {"@collection": self.name} @@ -1263,8 +1263,7 @@ def response_handler(resp: Response) -> Json: def add_index(self, data: Json) -> Result[Json]: """Create an index. - :param data: Index data. Must contain a "type" field - with the index type. + :param data: Index data. Must contain a "type" and "fields" attribute. :type data: dict :return: New index details. :rtype: dict @@ -1295,6 +1294,12 @@ def add_hash_index( ) -> Result[Json]: """Create a new hash index. + .. warning:: + + The index types `hash` and `skiplist` are aliases for the persistent + index type and should no longer be used to create new indexes. The + aliases will be removed in a future version. + :param fields: Document fields to index. :type fields: [str] :param unique: Whether the index is unique. @@ -1313,7 +1318,7 @@ def add_hash_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ - m = "add_hash_index is deprecated. Using add_index with {'type': 'hash'} instead." # noqa: E501 + m = "add_hash_index is deprecated. Using add_index with {'type': 'persistent'} instead." # noqa: E501 warn(m, DeprecationWarning, stacklevel=2) data: Json = {"type": "hash", "fields": fields} @@ -1342,6 +1347,12 @@ def add_skiplist_index( ) -> Result[Json]: """Create a new skiplist index. + .. warning:: + + The index types `hash` and `skiplist` are aliases for the persistent + index type and should no longer be used to create new indexes. The + aliases will be removed in a future version. + :param fields: Document fields to index. :type fields: [str] :param unique: Whether the index is unique. @@ -1360,7 +1371,7 @@ def add_skiplist_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ - m = "add_skiplist_index is deprecated. Using add_index with {'type': 'skiplist'} instead." # noqa: E501 + m = "add_skiplist_index is deprecated. Using add_index with {'type': 'persistent'} instead." # noqa: E501 warn(m, DeprecationWarning, stacklevel=2) data: Json = {"type": "skiplist", "fields": fields} @@ -1698,6 +1709,7 @@ def insert_many( keep_none: Optional[bool] = None, merge: Optional[bool] = None, refill_index_caches: Optional[bool] = None, + version_attribute: Optional[str] = None, ) -> Result[Union[bool, List[Union[Json, ArangoServerError]]]]: """Insert multiple documents. @@ -1752,6 +1764,9 @@ def insert_many( index caches if document insertions affect the edge index or cache-enabled persistent indexes. :type refill_index_caches: bool | None + :param version_attribute: support for simple external versioning to + document operations. + :type version_attribute: str :return: List of document metadata (e.g. document keys, revisions) and any exception, or True if parameter **silent** was set to True. :rtype: [dict | ArangoServerError] | bool @@ -1774,6 +1789,8 @@ def insert_many( params["keepNull"] = keep_none if merge is not None: params["mergeObjects"] = merge + if version_attribute is not None: + params["versionAttribute"] = version_attribute # New in ArangoDB 3.9.6 and 3.10.2 if refill_index_caches is not None: @@ -1820,6 +1837,7 @@ def update_many( silent: bool = False, refill_index_caches: Optional[bool] = None, raise_on_document_error: bool = False, + version_attribute: Optional[str] = None, ) -> Result[Union[bool, List[Union[Json, ArangoServerError]]]]: """Update multiple documents. @@ -1872,6 +1890,9 @@ def update_many( as opposed to returning the error as an object in the result list. Defaults to False. :type raise_on_document_error: bool + :param version_attribute: support for simple external versioning to + document operations. + :type version_attribute: str :return: List of document metadata (e.g. document keys, revisions) and any exceptions, or True if parameter **silent** was set to True. :rtype: [dict | ArangoError] | bool @@ -1888,6 +1909,8 @@ def update_many( } if sync is not None: params["waitForSync"] = sync + if version_attribute is not None: + params["versionAttribute"] = version_attribute # New in ArangoDB 3.9.6 and 3.10.2 if refill_index_caches is not None: @@ -1990,7 +2013,7 @@ def update_match( {f"LIMIT {limit}" if limit is not None else ""} UPDATE doc WITH @body IN @@collection OPTIONS {{ keepNull: @keep_none, mergeObjects: @merge {sync_val} }} - """ + """ # noqa: E201 E202 bind_vars = { "@collection": self.name, @@ -2024,6 +2047,7 @@ def replace_many( sync: Optional[bool] = None, silent: bool = False, refill_index_caches: Optional[bool] = None, + version_attribute: Optional[str] = None, ) -> Result[Union[bool, List[Union[Json, ArangoServerError]]]]: """Replace multiple documents. @@ -2065,6 +2089,9 @@ def replace_many( index caches if document operations affect the edge index or cache-enabled persistent indexes. :type refill_index_caches: bool | None + :param version_attribute: support for simple external versioning to + document operations. + :type version_attribute: str :return: List of document metadata (e.g. document keys, revisions) and any exceptions, or True if parameter **silent** was set to True. :rtype: [dict | ArangoServerError] | bool @@ -2079,6 +2106,8 @@ def replace_many( } if sync is not None: params["waitForSync"] = sync + if version_attribute is not None: + params["versionAttribute"] = version_attribute # New in ArangoDB 3.9.6 and 3.10.2 if refill_index_caches is not None: @@ -2169,7 +2198,7 @@ def replace_match( {f"LIMIT {limit}" if limit is not None else ""} REPLACE doc WITH @body IN @@collection {f"OPTIONS {{ {sync_val} }}" if sync_val else ""} - """ + """ # noqa: E201 E202 bind_vars = {"@collection": self.name, "body": body} @@ -2334,7 +2363,7 @@ def delete_match( {f"LIMIT {limit}" if limit is not None else ""} REMOVE doc IN @@collection {f"OPTIONS {{ {sync_val} }}" if sync_val else ""} - """ + """ # noqa: E201 E202 bind_vars = {"@collection": self.name} @@ -2553,6 +2582,7 @@ def insert( keep_none: Optional[bool] = None, merge: Optional[bool] = None, refill_index_caches: Optional[bool] = None, + version_attribute: Optional[str] = None, ) -> Result[Union[bool, Json]]: """Insert a new document. @@ -2591,6 +2621,9 @@ def insert( index caches if document insertions affect the edge index or cache-enabled persistent indexes. :type refill_index_caches: bool | None + :param version_attribute: support for simple external versioning to + document operations. + :type version_attribute: str :return: Document metadata (e.g. document key, revision) or True if parameter **silent** was set to True. :rtype: bool | dict @@ -2612,6 +2645,8 @@ def insert( params["keepNull"] = keep_none if merge is not None: params["mergeObjects"] = merge + if version_attribute is not None: + params["versionAttribute"] = version_attribute # New in ArangoDB 3.9.6 and 3.10.2 if refill_index_caches is not None: @@ -2650,6 +2685,7 @@ def update( sync: Optional[bool] = None, silent: bool = False, refill_index_caches: Optional[bool] = None, + version_attribute: Optional[str] = None, ) -> Result[Union[bool, Json]]: """Update a document. @@ -2680,6 +2716,9 @@ def update( index caches if document insertions affect the edge index or cache-enabled persistent indexes. :type refill_index_caches: bool | None + :param version_attribute: support for simple external versioning + to document operations. + :type version_attribute: str :return: Document metadata (e.g. document key, revision) or True if parameter **silent** was set to True. :rtype: bool | dict @@ -2698,6 +2737,9 @@ def update( if sync is not None: params["waitForSync"] = sync + if version_attribute is not None: + params["versionAttribute"] = version_attribute + # New in ArangoDB 3.9.6 and 3.10.2 if refill_index_caches is not None: params["refillIndexCaches"] = refill_index_caches @@ -2733,6 +2775,7 @@ def replace( sync: Optional[bool] = None, silent: bool = False, refill_index_caches: Optional[bool] = None, + version_attribute: Optional[str] = None, ) -> Result[Union[bool, Json]]: """Replace a document. @@ -2758,6 +2801,9 @@ def replace( index caches if document insertions affect the edge index or cache-enabled persistent indexes. :type refill_index_caches: bool | None + :param version_attribute: support for simple external versioning to + document operations. + :type version_attribute: str :return: Document metadata (e.g. document key, revision) or True if parameter **silent** was set to True. :rtype: bool | dict @@ -2774,6 +2820,9 @@ def replace( if sync is not None: params["waitForSync"] = sync + if version_attribute is not None: + params["versionAttribute"] = version_attribute + # New in ArangoDB 3.9.6 and 3.10.2 if refill_index_caches is not None: params["refillIndexCaches"] = refill_index_caches diff --git a/tests/test_collection.py b/tests/test_collection.py index a57aa6bb..e44600e1 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -369,8 +369,8 @@ def create_and_delete_collection(db, name): assert col.name == name assert db.has_collection(name) is True - hash_index = {"type": "hash", "fields": ["foo"]} - index_id = col.add_index(hash_index)["name"] + persistent_index = {"type": "perssitent", "fields": ["foo"]} + index_id = col.add_index(persistent_index)["name"] assert index_id == col.indexes()[-1]["name"] assert col.delete_index(index_id) is True diff --git a/tests/test_document.py b/tests/test_document.py index 8fcee98e..8e53ba26 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -1464,8 +1464,8 @@ def test_document_find_in_box(db, col, bad_col, geo, cluster): ) # Test find_in_box with non-geo index - hash_index = {"type": "hash", "fields": ["loc"]} - non_geo = col.add_index(hash_index) + persistent_index = {"type": "persistent", "fields": ["loc"]} + non_geo = col.add_index(persistent_index) with assert_raises(ValueError) as err: col.find_in_box( latitude1=0, From 8c954a3ff8be73a0b2d7d13fe1f4166f4d7aca65 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 20:23:43 +0300 Subject: [PATCH 05/14] Using persistent index instead of hash --- docs/overview.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/overview.rst b/docs/overview.rst index b31effe0..43cf2f99 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -29,8 +29,8 @@ Here is an example showing how **python-arango** client can be used: else: students = db.create_collection('students') - # Add a hash index to the collection. - students.add_index({'type': 'hash', 'fields': ['name'], 'unique': True}) + # Add a persistent index to the collection. + students.add_index({'type': 'persistent', 'fields': ['name'], 'unique': True}) # Truncate the collection. students.truncate() From 52ce22cde85e463c47f46d592f0910e13cc6a792 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 20:31:58 +0300 Subject: [PATCH 06/14] Fixing docs --- docs/indexes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/indexes.rst b/docs/indexes.rst index 876bb787..49fdc7e9 100644 --- a/docs/indexes.rst +++ b/docs/indexes.rst @@ -52,7 +52,7 @@ on fields ``_from`` and ``_to``. For more information on indexes, refer to index = cities.add_index(ttl_index) # Add MDI (multi-dimensional) index on field 'x' and 'y'. - mdi_index = {'type': 'mdi', 'fields': ['x', 'y'], 'field_value_types': ['double']} + mdi_index = {'type': 'mdi', 'fields': ['x', 'y'], 'fieldValueTypes': ['double']} index = cities.add_index(mdi_index) # Indexes may be added with a name that can be referred to in AQL queries. From a90f66b84a763a3b67f0142ea6d5adc45bcad693 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 20:48:10 +0300 Subject: [PATCH 07/14] Fixing typos --- docs/indexes.rst | 2 +- docs/overview.rst | 2 +- tests/test_collection.py | 2 +- tests/test_index.py | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/indexes.rst b/docs/indexes.rst index 49fdc7e9..8df3048f 100644 --- a/docs/indexes.rst +++ b/docs/indexes.rst @@ -52,7 +52,7 @@ on fields ``_from`` and ``_to``. For more information on indexes, refer to index = cities.add_index(ttl_index) # Add MDI (multi-dimensional) index on field 'x' and 'y'. - mdi_index = {'type': 'mdi', 'fields': ['x', 'y'], 'fieldValueTypes': ['double']} + mdi_index = {'type': 'mdi', 'fields': ['x', 'y'], 'fieldValueTypes': 'double'} index = cities.add_index(mdi_index) # Indexes may be added with a name that can be referred to in AQL queries. diff --git a/docs/overview.rst b/docs/overview.rst index 43cf2f99..053658df 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -30,7 +30,7 @@ Here is an example showing how **python-arango** client can be used: students = db.create_collection('students') # Add a persistent index to the collection. - students.add_index({'type': 'persistent', 'fields': ['name'], 'unique': True}) + students.add_index({'type': 'persistent', 'fields': ['name'], 'unique': False}) # Truncate the collection. students.truncate() diff --git a/tests/test_collection.py b/tests/test_collection.py index e44600e1..7ab72800 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -369,7 +369,7 @@ def create_and_delete_collection(db, name): assert col.name == name assert db.has_collection(name) is True - persistent_index = {"type": "perssitent", "fields": ["foo"]} + persistent_index = {"type": "persistent", "fields": ["foo"]} index_id = col.add_index(persistent_index)["name"] assert index_id == col.indexes()[-1]["name"] assert col.delete_index(index_id) is True diff --git a/tests/test_index.py b/tests/test_index.py index 99a77788..9c78fe88 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -83,6 +83,7 @@ def test_add_skiplist_index(icol): fields = ["attr1", "attr2"] result = icol.add_index( { + "type": "skiplist", "fields": fields, "unique": True, "sparse": True, From 5f6ba83b6406a50e0624eef4f488c454c464cbb9 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 21:16:09 +0300 Subject: [PATCH 08/14] Fixing tests --- arango/collection.py | 8 +++++--- tests/test_index.py | 40 ++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/arango/collection.py b/arango/collection.py index 0ec3c996..75e99deb 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1442,9 +1442,11 @@ def add_fulltext_index( name: Optional[str] = None, in_background: Optional[bool] = None, ) -> Result[Json]: - """Create a new fulltext index. This method is deprecated - in ArangoDB 3.10 and will be removed in a future version - of the driver. + """Create a new fulltext index. + + .. warning:: + This method is deprecated since ArangoDB 3.10 and will be removed + in a future version of the driver. :param fields: Document fields to index. :type fields: [str] diff --git a/tests/test_index.py b/tests/test_index.py index 9c78fe88..921dd93a 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -58,7 +58,7 @@ def test_add_hash_index(icol): "sparse": True, "deduplicate": True, "name": "hash_index", - "in_background": False, + "inBackground": False, } ) @@ -89,7 +89,7 @@ def test_add_skiplist_index(icol): "sparse": True, "deduplicate": True, "name": "skiplist_index", - "in_background": False, + "inBackground": False, } ) @@ -116,9 +116,9 @@ def test_add_geo_index(icol): { "type": "geo", "fields": ["attr1"], - "geo_json": True, + "geoJson": True, "name": "geo_index", - "in_background": True, + "inBackground": True, } ) @@ -140,7 +140,7 @@ def test_add_geo_index(icol): { "type": "geo", "fields": ["attr1", "attr2"], - "geo_json": False, + "geoJson": False, } ) expected_index = { @@ -169,9 +169,9 @@ def test_add_fulltext_index(icol): { "type": "fulltext", "fields": ["attr1"], - "min_length": 10, + "minLength": 10, "name": "fulltext_index", - "in_background": True, + "inBackground": True, } ) expected_index = { @@ -205,7 +205,7 @@ def test_add_persistent_index(icol): "unique": True, "sparse": True, "name": "persistent_index", - "in_background": True, + "inBackground": True, } ) expected_index = { @@ -230,9 +230,9 @@ def test_add_ttl_index(icol): { "type": "ttl", "fields": ["attr1"], - "expiry_time": 1000, + "expireAfter": 1000, "name": "ttl_index", - "in_background": True, + "inBackground": True, } ) expected_index = { @@ -280,9 +280,9 @@ def test_add_zkd_index(icol, db_version): { "type": "zkd", "fields": ["x", "y", "z"], - "field_value_types": "double", + "fieldValueTypes": "double", "name": "zkd_index", - "in_background": False, + "inBackground": False, "unique": False, } ) @@ -301,7 +301,9 @@ def test_add_zkd_index(icol, db_version): assert result["id"] in extract("id", icol.indexes()) with assert_raises(IndexCreateError) as err: - icol.add_zkd_index(field_value_types="integer", fields=["x", "y", "z"]) + icol.add_index( + {"type": "zkd", "fieldValueTypes": "integer", "fields": ["x", "y", "z"]} + ) assert err.value.error_code == 10 icol.delete_index(result["id"]) @@ -315,9 +317,9 @@ def test_add_mdi_index(icol, db_version): { "type": "mdi", "fields": ["x", "y", "z"], - "field_value_types": "double", + "fieldValueTypes": "double", "name": "mdi_index", - "in_background": False, + "inBackground": False, "unique": True, } ) @@ -336,7 +338,13 @@ def test_add_mdi_index(icol, db_version): assert result["id"] in extract("id", icol.indexes()) with assert_raises(IndexCreateError) as err: - icol.add_mdi_index(field_value_types="integer", fields=["x", "y", "z"]) + icol.add_index( + { + "type": "mdi", + "fieldValueTypes": "integer", + "fields": ["x", "y", "z"], + } + ) assert err.value.error_code == 10 icol.delete_index(result["id"]) From 6f1c1171aa7ec496cbe2cfeb038075a3151d8037 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 21:39:28 +0300 Subject: [PATCH 09/14] Removing unused argument --- arango/client.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/arango/client.py b/arango/client.py index 0ccaa19f..12f2bf11 100644 --- a/arango/client.py +++ b/arango/client.py @@ -199,7 +199,6 @@ def db( auth_method: str = "basic", user_token: Optional[str] = None, superuser_token: Optional[str] = None, - verify_certificate: bool = True, ) -> StandardDatabase: """Connect to an ArangoDB database and return the database API wrapper. @@ -228,8 +227,6 @@ def db( are ignored. This token is not refreshed automatically. Token expiry will not be checked. :type superuser_token: str - :param verify_certificate: Verify TLS certificates. - :type verify_certificate: bool :return: Standard database API wrapper. :rtype: arango.database.StandardDatabase :raise arango.exceptions.ServerConnectionError: If **verify** was set From 72e0c46ef1a87472ff30b078da16a896d9e3ba0f Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 21:46:20 +0300 Subject: [PATCH 10/14] Adding the formatter parameter --- arango/collection.py | 21 ++++++++++++--------- arango/formatter.py | 10 +++++++++- tests/test_index.py | 12 ++++++------ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/arango/collection.py b/arango/collection.py index 75e99deb..d05cc93c 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1260,11 +1260,14 @@ def response_handler(resp: Response) -> Json: return self._execute(request, response_handler) - def add_index(self, data: Json) -> Result[Json]: + def add_index(self, data: Json, formatter: bool = False) -> Result[Json]: """Create an index. :param data: Index data. Must contain a "type" and "fields" attribute. :type data: dict + :param formatter: If set to True, apply formatting to the returned result. + Most keys will be converted to snake case. + :type formatter: bool :return: New index details. :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. @@ -1279,7 +1282,7 @@ def add_index(self, data: Json) -> Result[Json]: def response_handler(resp: Response) -> Json: if not resp.is_success: raise IndexCreateError(resp, request) - return format_index(resp.body) + return format_index(resp.body, formatter) return self._execute(request, response_handler) @@ -1334,7 +1337,7 @@ def add_hash_index( if in_background is not None: data["inBackground"] = in_background - return self.add_index(data) + return self.add_index(data, formatter=True) def add_skiplist_index( self, @@ -1387,7 +1390,7 @@ def add_skiplist_index( if in_background is not None: data["inBackground"] = in_background - return self.add_index(data) + return self.add_index(data, formatter=True) def add_geo_index( self, @@ -1433,7 +1436,7 @@ def add_geo_index( if legacyPolygons is not None: data["legacyPolygons"] = legacyPolygons - return self.add_index(data) + return self.add_index(data, formatter=True) def add_fulltext_index( self, @@ -1472,7 +1475,7 @@ def add_fulltext_index( if in_background is not None: data["inBackground"] = in_background - return self.add_index(data) + return self.add_index(data, formatter=True) def add_persistent_index( self, @@ -1533,7 +1536,7 @@ def add_persistent_index( if cacheEnabled is not None: data["cacheEnabled"] = cacheEnabled - return self.add_index(data) + return self.add_index(data, formatter=True) def add_ttl_index( self, @@ -1566,7 +1569,7 @@ def add_ttl_index( if in_background is not None: data["inBackground"] = in_background - return self.add_index(data) + return self.add_index(data, formatter=True) def add_inverted_index( self, @@ -1653,7 +1656,7 @@ def add_inverted_index( if cache is not None: data["cache"] = cache - return self.add_index(data) + return self.add_index(data, formatter=True) def delete_index(self, index_id: str, ignore_missing: bool = False) -> Result[bool]: """Delete an index. diff --git a/arango/formatter.py b/arango/formatter.py index c948f279..5df9b553 100644 --- a/arango/formatter.py +++ b/arango/formatter.py @@ -20,14 +20,22 @@ def format_body(body: Json) -> Json: return body -def format_index(body: Json) -> Json: +def format_index(body: Json, formatter: bool = True) -> Json: """Format index data. :param body: Input body. :type body: dict + :param formatter: Convert (most) keys to snake_case. + :type formatter: bool :return: Formatted body. :rtype: dict """ + if not formatter: + body.pop("code") + body.pop("error") + body["id"] = body["id"].split("/", 1)[-1] + return body + result = {"id": body["id"].split("/", 1)[-1], "fields": body["fields"]} if "type" in body: result["type"] = body["type"] diff --git a/tests/test_index.py b/tests/test_index.py index 921dd93a..a5d0f5eb 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -127,7 +127,7 @@ def test_add_geo_index(icol): "type": "geo", "fields": ["attr1"], "unique": False, - "geo_json": True, + "geoJson": True, "name": "geo_index", } for key, value in expected_index.items(): @@ -178,7 +178,7 @@ def test_add_fulltext_index(icol): "sparse": True, "type": "fulltext", "fields": ["attr1"], - "min_length": 10, + "minLength": 10, "unique": False, "name": "fulltext_index", } @@ -238,7 +238,7 @@ def test_add_ttl_index(icol): expected_index = { "type": "ttl", "fields": ["attr1"], - "expiry_time": 1000, + "expireAfter": 1000, "name": "ttl_index", } for key, value in expected_index.items(): @@ -259,7 +259,7 @@ def test_add_inverted_index(icol, enterprise): analyzer="identity", primarySort={"cache": True, "fields": [{"field": "a", "direction": "asc"}]}, ) - expected_keys = ["primary_sort", "analyzer", "include_all_fields", "search_field"] + expected_keys = ["primarySort", "analyzer", "includeAllFields", "searchField"] if enterprise: parameters["cache"] = True @@ -291,7 +291,7 @@ def test_add_zkd_index(icol, db_version): "name": "zkd_index", "type": "zkd", "fields": ["x", "y", "z"], - "new": True, + "isNewlyCreated": True, "unique": False, } @@ -328,7 +328,7 @@ def test_add_mdi_index(icol, db_version): "name": "mdi_index", "type": "mdi", "fields": ["x", "y", "z"], - "new": True, + "isNewlyCreated": True, "unique": True, } From 6ba1d7a09cd1099319a212da9490ad230a4c3099 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Sat, 25 May 2024 21:55:00 +0300 Subject: [PATCH 11/14] Added note explaining the formatter parameter. --- arango/collection.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arango/collection.py b/arango/collection.py index d05cc93c..29fc98dd 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1263,10 +1263,23 @@ def response_handler(resp: Response) -> Json: def add_index(self, data: Json, formatter: bool = False) -> Result[Json]: """Create an index. + .. note:: + + As the `add_index` method was made available starting with driver + version 8, we have decided to depreciate the other `add_*_index` + methods, making this the official way to create indexes. While + the other methods still work, we recommend using this one instead. + Note that the other methods would use a formatter by default, + processing the index attributes returned by the server (for the + most part, it does a snake case conversion). This method skips that, + returning the raw index, except for the `id` attribute. However, + if you want the formatter to be applied for backwards compatibility, + you can set the `formatter` parameter to `True`. + :param data: Index data. Must contain a "type" and "fields" attribute. :type data: dict :param formatter: If set to True, apply formatting to the returned result. - Most keys will be converted to snake case. + Should only be used for backwards compatibility. :type formatter: bool :return: New index details. :rtype: dict From a03ec2d5bb196b44a56797ff18aa2df4611594f9 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Wed, 29 May 2024 21:08:37 +0300 Subject: [PATCH 12/14] Update arango/collection.py Co-authored-by: Anthony Mahanna <43019056+aMahanna@users.noreply.github.com> --- arango/collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arango/collection.py b/arango/collection.py index 29fc98dd..bcff68ac 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1266,7 +1266,7 @@ def add_index(self, data: Json, formatter: bool = False) -> Result[Json]: .. note:: As the `add_index` method was made available starting with driver - version 8, we have decided to depreciate the other `add_*_index` + version 8, we have decided to deprecate the other `add_*_index` methods, making this the official way to create indexes. While the other methods still work, we recommend using this one instead. Note that the other methods would use a formatter by default, From b6e74ca763bf22cfbd452d2d99cdf49abbc7cdb7 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Wed, 29 May 2024 21:09:23 +0300 Subject: [PATCH 13/14] Update arango/collection.py Co-authored-by: Anthony Mahanna <43019056+aMahanna@users.noreply.github.com> --- arango/collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arango/collection.py b/arango/collection.py index bcff68ac..992549a5 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1387,7 +1387,7 @@ def add_skiplist_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ - m = "add_skiplist_index is deprecated. Using add_index with {'type': 'persistent'} instead." # noqa: E501 + m = "add_skiplist_index is deprecated. Using add_index with {'type': 'skiplist'} instead." # noqa: E501 warn(m, DeprecationWarning, stacklevel=2) data: Json = {"type": "skiplist", "fields": fields} From 8c1ef8e84442dd1ed9a3020288b8c4c2147aebf0 Mon Sep 17 00:00:00 2001 From: Alex Petenchea Date: Wed, 29 May 2024 21:10:54 +0300 Subject: [PATCH 14/14] Changed warning --- arango/collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arango/collection.py b/arango/collection.py index 992549a5..054b0a1e 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1334,7 +1334,7 @@ def add_hash_index( :rtype: dict :raise arango.exceptions.IndexCreateError: If create fails. """ - m = "add_hash_index is deprecated. Using add_index with {'type': 'persistent'} instead." # noqa: E501 + m = "add_hash_index is deprecated. Using add_index with {'type': 'hash'} instead." # noqa: E501 warn(m, DeprecationWarning, stacklevel=2) data: Json = {"type": "hash", "fields": fields}