Fix bug with graph traversal expression parsing
This commit is contained in:
parent
91a859f6b0
commit
2c97d65e97
2 changed files with 17 additions and 6 deletions
|
@ -2,7 +2,7 @@ use crate::sql::comment::mightbespace;
|
||||||
use crate::sql::comment::shouldbespace;
|
use crate::sql::comment::shouldbespace;
|
||||||
use crate::sql::error::IResult;
|
use crate::sql::error::IResult;
|
||||||
use crate::sql::idiom::{idiom, Idiom};
|
use crate::sql::idiom::{idiom, Idiom};
|
||||||
use crate::sql::table::{tables, Tables};
|
use crate::sql::table::{table, tables, Tables};
|
||||||
use crate::sql::value::{value, Value};
|
use crate::sql::value::{value, Value};
|
||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag_no_case;
|
use nom::bytes::complete::tag_no_case;
|
||||||
|
@ -119,14 +119,14 @@ fn graph_both(i: &str) -> IResult<&str, Graph> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simple(i: &str) -> IResult<&str, (Tables, Option<Value>, Option<Idiom>)> {
|
fn simple(i: &str) -> IResult<&str, (Tables, Option<Value>, Option<Idiom>)> {
|
||||||
let (i, w) = what(i)?;
|
let (i, w) = alt((any, single))(i)?;
|
||||||
Ok((i, (w, None, None)))
|
Ok((i, (w, None, None)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn custom(i: &str) -> IResult<&str, (Tables, Option<Value>, Option<Idiom>)> {
|
fn custom(i: &str) -> IResult<&str, (Tables, Option<Value>, Option<Idiom>)> {
|
||||||
let (i, _) = char('(')(i)?;
|
let (i, _) = char('(')(i)?;
|
||||||
let (i, _) = mightbespace(i)?;
|
let (i, _) = mightbespace(i)?;
|
||||||
let (i, w) = what(i)?;
|
let (i, w) = alt((any, multi))(i)?;
|
||||||
let (i, c) = opt(cond)(i)?;
|
let (i, c) = opt(cond)(i)?;
|
||||||
let (i, a) = opt(alias)(i)?;
|
let (i, a) = opt(alias)(i)?;
|
||||||
let (i, _) = mightbespace(i)?;
|
let (i, _) = mightbespace(i)?;
|
||||||
|
@ -134,9 +134,14 @@ fn custom(i: &str) -> IResult<&str, (Tables, Option<Value>, Option<Idiom>)> {
|
||||||
Ok((i, (w, c, a)))
|
Ok((i, (w, c, a)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn what(i: &str) -> IResult<&str, Tables> {
|
fn single(i: &str) -> IResult<&str, Tables> {
|
||||||
let (i, v) = alt((any, tables))(i)?;
|
let (i, v) = table(i)?;
|
||||||
Ok((i, v))
|
Ok((i, Tables::from(v)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn multi(i: &str) -> IResult<&str, Tables> {
|
||||||
|
let (i, v) = tables(i)?;
|
||||||
|
Ok((i, Tables::from(v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn any(i: &str) -> IResult<&str, Tables> {
|
fn any(i: &str) -> IResult<&str, Tables> {
|
||||||
|
|
|
@ -13,6 +13,12 @@ use std::str;
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
pub struct Tables(pub Vec<Table>);
|
pub struct Tables(pub Vec<Table>);
|
||||||
|
|
||||||
|
impl From<Table> for Tables {
|
||||||
|
fn from(v: Table) -> Self {
|
||||||
|
Tables(vec![v])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Deref for Tables {
|
impl Deref for Tables {
|
||||||
type Target = Vec<Table>;
|
type Target = Vec<Table>;
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
|
Loading…
Reference in a new issue