From 6621683c5d4d52cef445da21cf5251487f3c80a5 Mon Sep 17 00:00:00 2001 From: Edgar Brissow Date: Mon, 30 Sep 2024 16:11:40 -0300 Subject: [PATCH 1/2] Commit to prevent update in the same transition --- hyperon_das_atomdb/database.py | 1 + tests/integration/adapters/test_redis_mongo.py | 1 + 2 files changed, 2 insertions(+) diff --git a/hyperon_das_atomdb/database.py b/hyperon_das_atomdb/database.py index 07268966..8aa6b27f 100644 --- a/hyperon_das_atomdb/database.py +++ b/hyperon_das_atomdb/database.py @@ -898,6 +898,7 @@ def commit(self, **kwargs) -> None: This method is intended to be implemented by subclasses to handle the commit operation, which may involve persisting changes to a storage backend or performing other necessary actions to finalize the current state of the database. + Updates of atoms aren't allowed on the same transaction. Args: **kwargs: Additional keyword arguments that may be used by the implementation of the diff --git a/tests/integration/adapters/test_redis_mongo.py b/tests/integration/adapters/test_redis_mongo.py index 2ba9909d..baab27c0 100644 --- a/tests/integration/adapters/test_redis_mongo.py +++ b/tests/integration/adapters/test_redis_mongo.py @@ -39,6 +39,7 @@ def _add_atoms(self, db: RedisMongoDB): db.add_link(link) for link in similarity_docs.values(): db.add_link(link) + db.commit() def _connect_db(self): db = RedisMongoDB( From 9469f96a5c1f155600ee5fef789fb67d81c16b0d Mon Sep 17 00:00:00 2001 From: Edgar Brissow Date: Mon, 30 Sep 2024 16:29:47 -0300 Subject: [PATCH 2/2] Fix commit --- tests/integration/adapters/test_redis_mongo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/adapters/test_redis_mongo.py b/tests/integration/adapters/test_redis_mongo.py index baab27c0..3d79b663 100644 --- a/tests/integration/adapters/test_redis_mongo.py +++ b/tests/integration/adapters/test_redis_mongo.py @@ -39,7 +39,6 @@ def _add_atoms(self, db: RedisMongoDB): db.add_link(link) for link in similarity_docs.values(): db.add_link(link) - db.commit() def _connect_db(self): db = RedisMongoDB( @@ -792,6 +791,7 @@ def test_get_matched_with_pagination(self, _cleanup, _db: RedisMongoDB): def test_create_field_index(self, _cleanup, _db: RedisMongoDB): db = _db self._add_atoms(db) + db.commit() db.add_link( { "type": "Similarity",