diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index 19795e90..2590241e 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -847,20 +847,10 @@ impl Value { } } - pub fn make_table(self) -> Value { + pub fn could_be_table(self) -> Value { match self { - Value::Table(_) => self, - Value::Strand(v) => Value::Table(Table(v.0)), - _ => 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)), + Value::Strand(v) => Table::from(v.0).into(), + _ => self, } } diff --git a/src/net/rpc.rs b/src/net/rpc.rs index 717e46f1..42e95ef3 100644 --- a/src/net/rpc.rs +++ b/src/net/rpc.rs @@ -373,7 +373,7 @@ impl Rpc { let sql = "LIVE SELECT * FROM $tb"; // Specify the query parameters let var = Some(map! { - String::from("tb") => tb.make_table(), + String::from("tb") => tb.could_be_table(), => &self.vars }); // Execute the query on the database @@ -427,7 +427,7 @@ impl Rpc { let sql = "SELECT * FROM $what"; // Specify the query parameters let var = Some(map! { - String::from("what") => what.make_table_or_thing(), + String::from("what") => what.could_be_table(), => &self.vars }); // Execute the query on the database @@ -451,8 +451,8 @@ impl Rpc { let sql = "CREATE $what CONTENT $data RETURN AFTER"; // Specify the query parameters let var = Some(map! { - String::from("what") => what.make_table_or_thing(), String::from("data") => data.into().into(), + String::from("what") => what.could_be_table(), => &self.vars }); // Execute the query on the database @@ -476,8 +476,8 @@ impl Rpc { let sql = "UPDATE $what CONTENT $data RETURN AFTER"; // Specify the query parameters let var = Some(map! { - String::from("what") => what.make_table_or_thing(), String::from("data") => data.into().into(), + String::from("what") => what.could_be_table(), => &self.vars }); // Execute the query on the database @@ -501,8 +501,8 @@ impl Rpc { let sql = "UPDATE $what MERGE $data RETURN AFTER"; // Specify the query parameters let var = Some(map! { - String::from("what") => what.make_table_or_thing(), String::from("data") => data.into().into(), + String::from("what") => what.could_be_table(), => &self.vars }); // Execute the query on the database @@ -526,8 +526,8 @@ impl Rpc { let sql = "UPDATE $what PATCH $data RETURN DIFF"; // Specify the query parameters let var = Some(map! { - String::from("what") => what.make_table_or_thing(), String::from("data") => data.into().into(), + String::from("what") => what.could_be_table(), => &self.vars }); // Execute the query on the database @@ -551,7 +551,7 @@ impl Rpc { let sql = "DELETE $what"; // Specify the query parameters let var = Some(map! { - String::from("what") => what.make_table_or_thing(), + String::from("what") => what.could_be_table(), => &self.vars }); // Execute the query on the database