Skip to content

feat: make upsert_edge type-aware with property update support#25

Open
anonenity wants to merge 3 commits intocolliery-io:mainfrom
anonenity:feature/relation_type_filter
Open

feat: make upsert_edge type-aware with property update support#25
anonenity wants to merge 3 commits intocolliery-io:mainfrom
anonenity:feature/relation_type_filter

Conversation

@anonenity
Copy link

Summary

  • upsert_edge now checks for edges of the same relationship type before deciding to create or update, instead of checking for any edge between two nodes
  • Existing same-type edges have their properties updated via SET (merge semantics), preserving properties not included in the update
  • Applied to both Rust and Python bindings

Problem

Previously, upsert_edge called has_edge(source, target) which matched any edge type. This caused two bugs:

  1. Could not create multiple relationship types between the same node pair -- the second upsert_edge would see the first edge and silently no-op
  2. No way to update edge properties through the Graph API -- existing edges were never modified

upsert_edge now checks for edges of the same relationship type rather
than any edge between two nodes, allowing multiple relationship types
between the same node pair. Existing edges are updated via SET (merge
semantics) instead of being silently skipped.
@anonenity anonenity force-pushed the feature/relation_type_filter branch from 504435f to 1ffca22 Compare February 15, 2026 17:24
Now that upsert_edge supports multiple relationship types between the
same node pair, has_edge/get_edge/delete_edge need an optional rel_type
parameter to address edges individually. These tests document the
expected API and currently fail with TypeError.
@dylanbstorey
Copy link
Contributor

Hey @anonenity — nice fix, the type-aware MERGE approach is the right call. I pushed a commit with three failing tests that highlight an API gap opened up by this change:

  • test_get_edge_by_type — with two edge types between the same pair, get_edge has no way to request a specific one
  • test_delete_edge_by_typedelete_edge nukes all edges between a pair instead of just the specified type
  • test_has_edge_by_typehas_edge can't check for a specific relationship type

All three fail with TypeError. Now that upsert_edge supports multiple typed edges between the same nodes, the rest of the edge API needs to keep up. Can you make these tests pass?

Adds an optional rel_type parameter to get_edge, has_edge, and delete_edge
in both Rust and Python bindings so callers can target a specific relationship
type. Without rel_type, behaviour is unchanged (wildcard match).
@anonenity
Copy link
Author

Hey @dylanbstorey, thanks! All three tests passing now. Agreed, type-aware MERGE is right here. Added optional rel_type to get_edge, has_edge, and delete_edge across both bindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants