34 lines
671 B
Rust
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());
|
|
}
|
|
}
|