Skip to content

Commit

Permalink
Edge labels should rely on Labels type, not string (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlemesle committed Feb 19, 2023
1 parent 6f3c8e3 commit 7f991f3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl AnonymousTraversalSource {

pub fn add_e<A>(&self, label: A) -> TraversalBuilder
where
A: Into<String>,
A: Into<Labels>,
{
self.traversal.clone().add_e(label)
}
Expand Down
8 changes: 5 additions & 3 deletions gremlin-client/src/process/traversal/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ impl TraversalBuilder {

pub fn add_e<A>(mut self, label: A) -> Self
where
A: Into<String>,
A: Into<Labels>,
{
self.bytecode
.add_step(String::from("addE"), vec![label.into().into()]);
self.bytecode.add_step(
String::from("addE"),
label.into().0.into_iter().map(GValue::from).collect(),
);

self
}
Expand Down
2 changes: 1 addition & 1 deletion gremlin-client/src/process/traversal/graph_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<S, E: FromGValue, T: Terminator<E>> GraphTraversal<S, E, T> {

pub fn add_e<A>(mut self, label: A) -> GraphTraversal<S, Edge, T>
where
A: Into<String>,
A: Into<Labels>,
T: Terminator<Edge>,
{
self.builder = self.builder.add_e(label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,15 @@ impl<A: Terminator<GValue>> GraphTraversalSource<A> {

pub fn add_e<T>(&self, label: T) -> GraphTraversal<Edge, Edge, A>
where
T: Into<String>,
T: Into<Labels>,
A: Terminator<Edge>,
{
let mut code = Bytecode::new();

code.add_step(String::from("addE"), vec![label.into().into()]);
code.add_step(
String::from("addE"),
label.into().0.into_iter().map(GValue::from).collect(),
);

GraphTraversal::new(self.term.clone(), TraversalBuilder::new(code))
}
Expand Down

0 comments on commit 7f991f3

Please sign in to comment.