mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
remove conflict constraint name from relation_repository.py
Signed-off-by: phernandez <paul@basicmachines.co>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user