Fix querying complex edge table (#4391)

This commit is contained in:
Micha de Vries 2024-07-20 15:19:08 +02:00 committed by GitHub
parent c415d37a72
commit 4bd1185ff9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 3 deletions

View file

@ -427,7 +427,7 @@ impl<'a> Processor<'a> {
Dir::In => e Dir::In => e
.what .what
.iter() .iter()
.map(|v| v.to_string()) .map(|v| v.0.to_owned())
.map(|v| { .map(|v| {
( (
graph::ftprefix(ns, db, tb, id, &e.dir, &v), graph::ftprefix(ns, db, tb, id, &e.dir, &v),
@ -439,7 +439,7 @@ impl<'a> Processor<'a> {
Dir::Out => e Dir::Out => e
.what .what
.iter() .iter()
.map(|v| v.to_string()) .map(|v| v.0.to_owned())
.map(|v| { .map(|v| {
( (
graph::ftprefix(ns, db, tb, id, &e.dir, &v), graph::ftprefix(ns, db, tb, id, &e.dir, &v),
@ -451,7 +451,7 @@ impl<'a> Processor<'a> {
Dir::Both => e Dir::Both => e
.what .what
.iter() .iter()
.map(|v| v.to_string()) .map(|v| v.0.to_owned())
.flat_map(|v| { .flat_map(|v| {
vec![ vec![
( (

View file

@ -180,3 +180,30 @@ async fn relate_with_param_or_subquery() -> Result<(), Error> {
assert_eq!(tmp, val); assert_eq!(tmp, val);
Ok(()) Ok(())
} }
#[tokio::test]
async fn relate_with_complex_table() -> Result<(), Error> {
let sql = "
CREATE a:1, a:2;
RELATE a:1->`-`:`-`->a:2;
select ->`-` as rel from a:1;
";
let dbs = new_ds().await?;
let ses = Session::owner().with_ns("test").with_db("test");
let res = &mut dbs.execute(sql, &ses, None).await?;
assert_eq!(res.len(), 3);
//
let tmp = res.remove(0).result?;
let val = Value::parse("[{ id: a:1 }, { id: a:2 }]");
assert_eq!(tmp, val);
//
let tmp = res.remove(0).result?;
let val = Value::parse("[{ id: `-`:`-`, in: a:1, out: a:2 }]");
assert_eq!(tmp, val);
//
let tmp = res.remove(0).result?;
let val = Value::parse("[{ rel: [`-`:`-`] }]");
assert_eq!(tmp, val);
//
Ok(())
}