Skip to content

Commit

Permalink
Merge d8d4f95 into 45d56c9
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeepee committed Sep 25, 2020
2 parents 45d56c9 + d8d4f95 commit c0987e0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
7 changes: 3 additions & 4 deletions gremlin-cli/src/actions/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ impl Action for FallbackAction {
) -> Vec<crate::command::Command> {
if cmd.trim().starts_with(&ctx.alias) {
match ctx.client {
Some(ref client) => vec![Command::Exec(Box::new(execute_query(
client.clone(),
cmd,
)))],
Some(ref client) => {
vec![Command::Exec(Box::new(execute_query(client.clone(), cmd)))]
}
None => vec![Command::Print(Some(String::from("Not connected!")))],
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion gremlin-cli/src/print/glist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn fmt(list: &List) -> Result<String> {
Ok(format!(
"[{}]",
list.iter()
.map(|value| print::fmt(value))
.map(|value| print::fmt(value))
.collect::<Result<Vec<String>>>()?
.join(",")
))
Expand Down
2 changes: 1 addition & 1 deletion gremlin-cli/src/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn fmt(value: &GValue) -> Result<String> {
let result = match value {
GValue::Vertex(v) => vertex::fmt(v),
GValue::Edge(e) => edge::fmt(e),
GValue::Map(map) => map::fmt(map)?,
GValue::Map(map) => map::fmt(map)?,
GValue::List(list) => glist::fmt(list)?,
GValue::Int32(n) => n.to_string(),
GValue::Int64(n) => n.to_string(),
Expand Down
14 changes: 14 additions & 0 deletions gremlin-client/src/process/traversal/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ impl TraversalBuilder {
self
}

pub fn property_many<A>(mut self, values: Vec<(String, A)>) -> Self
where
A: Into<GValue>,
{
for property in values {
self.bytecode.add_step(
String::from("property"),
vec![property.0.into(), property.1.into()],
)
}

self
}

pub fn property_with_cardinality<A>(
mut self,
cardinality: Cardinality,
Expand Down
14 changes: 14 additions & 0 deletions gremlin-client/src/structure/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,20 @@ impl std::convert::TryFrom<GValue> for Date {
}
}

impl std::convert::TryFrom<GValue> for bool {
type Error = crate::GremlinError;

fn try_from(value: GValue) -> GremlinResult<Self> {
match value {
GValue::Bool(val) => Ok(val),
_ => Err(GremlinError::Cast(format!(
"Cannot cast {:?} to bool",
value
))),
}
}
}

fn from_list<T>(glist: List) -> GremlinResult<T>
where
T: std::convert::TryFrom<GValue, Error = GremlinError>,
Expand Down

0 comments on commit c0987e0

Please sign in to comment.