From 0eaf30bb064fc199b86e555f99a782a1672542b7 Mon Sep 17 00:00:00 2001 From: phernandez Date: Sun, 30 Nov 2025 19:30:54 -0600 Subject: [PATCH] remove conflict constraint name from relation_repository.py Signed-off-by: phernandez --- src/basic_memory/markdown/plugins.py | 2 +- src/basic_memory/repository/relation_repository.py | 8 ++------ tests/markdown/test_entity_parser.py | 2 +- tests/markdown/test_markdown_plugins.py | 4 ++-- tests/markdown/test_parser_edge_cases.py | 2 +- tests/services/test_entity_service.py | 14 +++++++------- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/basic_memory/markdown/plugins.py b/src/basic_memory/markdown/plugins.py index 268ec493..3bdc0682 100644 --- a/src/basic_memory/markdown/plugins.py +++ b/src/basic_memory/markdown/plugins.py @@ -162,7 +162,7 @@ def parse_inline_relations(content: str) -> List[Dict[str, Any]]: target = content[start + 2 : end].strip() if target: - relations.append({"type": "links to", "target": target, "context": None}) + relations.append({"type": "links_to", "target": target, "context": None}) start = end + 2 diff --git a/src/basic_memory/repository/relation_repository.py b/src/basic_memory/repository/relation_repository.py index 00a07db3..93d1d0b9 100644 --- a/src/basic_memory/repository/relation_repository.py +++ b/src/basic_memory/repository/relation_repository.py @@ -132,15 +132,11 @@ class RelationRepository(Repository[Relation]): if dialect_name == "postgresql": stmt = pg_insert(Relation).values(values) - stmt = stmt.on_conflict_do_nothing( - index_elements=["from_id", "to_name", "relation_type"] - ) + stmt = stmt.on_conflict_do_nothing() else: # SQLite stmt = sqlite_insert(Relation).values(values) - stmt = stmt.on_conflict_do_nothing( - index_elements=["from_id", "to_name", "relation_type"] - ) + stmt = stmt.on_conflict_do_nothing() result = await session.execute(stmt) return result.rowcount if result.rowcount else 0 diff --git a/tests/markdown/test_entity_parser.py b/tests/markdown/test_entity_parser.py index c252025c..62fa939b 100644 --- a/tests/markdown/test_entity_parser.py +++ b/tests/markdown/test_entity_parser.py @@ -179,7 +179,7 @@ async def test_parse_file_without_section_headers(project_config, entity_parser) assert entity.observations[0].tags == ["test"] assert len(entity.relations) == 2 - assert entity.relations[0].type == "links to" + assert entity.relations[0].type == "links_to" assert entity.relations[0].target == "Random Link" assert entity.relations[1].type == "references" diff --git a/tests/markdown/test_markdown_plugins.py b/tests/markdown/test_markdown_plugins.py index ae069f6b..e68376f3 100644 --- a/tests/markdown/test_markdown_plugins.py +++ b/tests/markdown/test_markdown_plugins.py @@ -181,7 +181,7 @@ def test_relation_plugin(): token = [t for t in md.parse(content) if t.type == "inline"][0] rels = token.meta["relations"] assert len(rels) == 2 - assert rels[0]["type"] == "links to" + assert rels[0]["type"] == "links_to" assert rels[0]["target"] == "Link" assert rels[1]["target"] == "Another Link" @@ -246,4 +246,4 @@ def test_combined_plugins(): text_token = inline_tokens[4] assert "relations" in text_token.meta link = text_token.meta["relations"][0] - assert link["type"] == "links to" + assert link["type"] == "links_to" diff --git a/tests/markdown/test_parser_edge_cases.py b/tests/markdown/test_parser_edge_cases.py index 78404a48..32a961c6 100644 --- a/tests/markdown/test_parser_edge_cases.py +++ b/tests/markdown/test_parser_edge_cases.py @@ -88,7 +88,7 @@ async def test_missing_sections(tmp_path): entity = await parser.parse_file(test_file) assert len(entity.relations) == 1 assert entity.relations[0].target == "links" - assert entity.relations[0].type == "links to" + assert entity.relations[0].type == "links_to" @pytest.mark.asyncio diff --git a/tests/services/test_entity_service.py b/tests/services/test_entity_service.py index a650d7ea..b17d44c1 100644 --- a/tests/services/test_entity_service.py +++ b/tests/services/test_entity_service.py @@ -432,14 +432,14 @@ async def test_create_with_content(entity_service: EntityService, file_service: assert entity.observations[0].context == "Reduces merge conflicts" assert len(entity.relations) == 4 - assert entity.relations[0].relation_type == "links to" + assert entity.relations[0].relation_type == "links_to" assert entity.relations[0].to_name == "Git" - assert entity.relations[1].relation_type == "links to" + assert entity.relations[1].relation_type == "links_to" assert entity.relations[1].to_name == "Trunk Based Development" assert entity.relations[2].relation_type == "implements" assert entity.relations[2].to_name == "Branch Strategy" assert entity.relations[2].context == "Our standard workflow" - assert entity.relations[3].relation_type == "links to" + assert entity.relations[3].relation_type == "links_to" assert entity.relations[3].to_name == "Git Cheat Sheet" # Verify file has new content but preserved metadata @@ -557,14 +557,14 @@ async def test_update_with_content(entity_service: EntityService, file_service: assert entity.observations[0].context == "Reduces merge conflicts" assert len(entity.relations) == 4 - assert entity.relations[0].relation_type == "links to" + assert entity.relations[0].relation_type == "links_to" assert entity.relations[0].to_name == "Git" - assert entity.relations[1].relation_type == "links to" + assert entity.relations[1].relation_type == "links_to" assert entity.relations[1].to_name == "Trunk Based Development" assert entity.relations[2].relation_type == "implements" assert entity.relations[2].to_name == "Branch Strategy" assert entity.relations[2].context == "Our standard workflow" - assert entity.relations[3].relation_type == "links to" + assert entity.relations[3].relation_type == "links_to" assert entity.relations[3].to_name == "Git Cheat Sheet" # Verify file has new content but preserved metadata @@ -1772,7 +1772,7 @@ async def test_move_entity_with_complex_observations( # Check relations relation_types = {rel.relation_type for rel in moved_entity.relations} assert "implements" in relation_types - assert "links to" in relation_types + assert "links_to" in relation_types relation_targets = {rel.to_name for rel in moved_entity.relations} assert "Branch Strategy" in relation_targets