Change method signature for converting strings to table names
This commit is contained in:
parent
3cbb5eed78
commit
d12384f3fb
2 changed files with 10 additions and 20 deletions
|
@ -847,20 +847,10 @@ impl Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_table(self) -> Value {
|
pub fn could_be_table(self) -> Value {
|
||||||
match self {
|
match self {
|
||||||
Value::Table(_) => self,
|
Value::Strand(v) => Table::from(v.0).into(),
|
||||||
Value::Strand(v) => Value::Table(Table(v.0)),
|
_ => self,
|
||||||
_ => Value::Table(Table(self.as_strand().0)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn make_table_or_thing(self) -> Value {
|
|
||||||
match self {
|
|
||||||
Value::Table(_) => self,
|
|
||||||
Value::Thing(_) => self,
|
|
||||||
Value::Strand(v) => Value::Table(Table(v.0)),
|
|
||||||
_ => Value::Table(Table(self.as_strand().0)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,7 @@ impl Rpc {
|
||||||
let sql = "LIVE SELECT * FROM $tb";
|
let sql = "LIVE SELECT * FROM $tb";
|
||||||
// Specify the query parameters
|
// Specify the query parameters
|
||||||
let var = Some(map! {
|
let var = Some(map! {
|
||||||
String::from("tb") => tb.make_table(),
|
String::from("tb") => tb.could_be_table(),
|
||||||
=> &self.vars
|
=> &self.vars
|
||||||
});
|
});
|
||||||
// Execute the query on the database
|
// Execute the query on the database
|
||||||
|
@ -427,7 +427,7 @@ impl Rpc {
|
||||||
let sql = "SELECT * FROM $what";
|
let sql = "SELECT * FROM $what";
|
||||||
// Specify the query parameters
|
// Specify the query parameters
|
||||||
let var = Some(map! {
|
let var = Some(map! {
|
||||||
String::from("what") => what.make_table_or_thing(),
|
String::from("what") => what.could_be_table(),
|
||||||
=> &self.vars
|
=> &self.vars
|
||||||
});
|
});
|
||||||
// Execute the query on the database
|
// Execute the query on the database
|
||||||
|
@ -451,8 +451,8 @@ impl Rpc {
|
||||||
let sql = "CREATE $what CONTENT $data RETURN AFTER";
|
let sql = "CREATE $what CONTENT $data RETURN AFTER";
|
||||||
// Specify the query parameters
|
// Specify the query parameters
|
||||||
let var = Some(map! {
|
let var = Some(map! {
|
||||||
String::from("what") => what.make_table_or_thing(),
|
|
||||||
String::from("data") => data.into().into(),
|
String::from("data") => data.into().into(),
|
||||||
|
String::from("what") => what.could_be_table(),
|
||||||
=> &self.vars
|
=> &self.vars
|
||||||
});
|
});
|
||||||
// Execute the query on the database
|
// Execute the query on the database
|
||||||
|
@ -476,8 +476,8 @@ impl Rpc {
|
||||||
let sql = "UPDATE $what CONTENT $data RETURN AFTER";
|
let sql = "UPDATE $what CONTENT $data RETURN AFTER";
|
||||||
// Specify the query parameters
|
// Specify the query parameters
|
||||||
let var = Some(map! {
|
let var = Some(map! {
|
||||||
String::from("what") => what.make_table_or_thing(),
|
|
||||||
String::from("data") => data.into().into(),
|
String::from("data") => data.into().into(),
|
||||||
|
String::from("what") => what.could_be_table(),
|
||||||
=> &self.vars
|
=> &self.vars
|
||||||
});
|
});
|
||||||
// Execute the query on the database
|
// Execute the query on the database
|
||||||
|
@ -501,8 +501,8 @@ impl Rpc {
|
||||||
let sql = "UPDATE $what MERGE $data RETURN AFTER";
|
let sql = "UPDATE $what MERGE $data RETURN AFTER";
|
||||||
// Specify the query parameters
|
// Specify the query parameters
|
||||||
let var = Some(map! {
|
let var = Some(map! {
|
||||||
String::from("what") => what.make_table_or_thing(),
|
|
||||||
String::from("data") => data.into().into(),
|
String::from("data") => data.into().into(),
|
||||||
|
String::from("what") => what.could_be_table(),
|
||||||
=> &self.vars
|
=> &self.vars
|
||||||
});
|
});
|
||||||
// Execute the query on the database
|
// Execute the query on the database
|
||||||
|
@ -526,8 +526,8 @@ impl Rpc {
|
||||||
let sql = "UPDATE $what PATCH $data RETURN DIFF";
|
let sql = "UPDATE $what PATCH $data RETURN DIFF";
|
||||||
// Specify the query parameters
|
// Specify the query parameters
|
||||||
let var = Some(map! {
|
let var = Some(map! {
|
||||||
String::from("what") => what.make_table_or_thing(),
|
|
||||||
String::from("data") => data.into().into(),
|
String::from("data") => data.into().into(),
|
||||||
|
String::from("what") => what.could_be_table(),
|
||||||
=> &self.vars
|
=> &self.vars
|
||||||
});
|
});
|
||||||
// Execute the query on the database
|
// Execute the query on the database
|
||||||
|
@ -551,7 +551,7 @@ impl Rpc {
|
||||||
let sql = "DELETE $what";
|
let sql = "DELETE $what";
|
||||||
// Specify the query parameters
|
// Specify the query parameters
|
||||||
let var = Some(map! {
|
let var = Some(map! {
|
||||||
String::from("what") => what.make_table_or_thing(),
|
String::from("what") => what.could_be_table(),
|
||||||
=> &self.vars
|
=> &self.vars
|
||||||
});
|
});
|
||||||
// Execute the query on the database
|
// Execute the query on the database
|
||||||
|
|
Loading…
Reference in a new issue