surrealpatch/lib/src/sql/value/rid.rs
2022-09-30 21:33:33 +01:00

34 lines
671 B
Rust

use crate::sql::paths::ID;
use crate::sql::value::Value;
impl Value {
pub fn rid(&self) -> Value {
self.pick(&*ID)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::sql::id::Id;
use crate::sql::test::Parse;
use crate::sql::thing::Thing;
#[tokio::test]
async fn rid_none() {
let val = Value::parse("{ test: { other: null, something: 123 } }");
let res = Value::None;
assert_eq!(res, val.rid());
}
#[tokio::test]
async fn rid_some() {
let val = Value::parse("{ id: test:id, test: { other: null, something: 123 } }");
let res = Value::Thing(Thing {
tb: String::from("test"),
id: Id::from("id"),
});
assert_eq!(res, val.rid());
}
}