Removes old alternative syntax for geometry and record ()

This commit is contained in:
Emmanuel Keller 2024-05-14 10:23:07 +01:00 committed by GitHub
parent 6277aab0e1
commit 51aea4ff8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 57 deletions
core/src/syn/parser
lib/tests

View file

@ -75,61 +75,30 @@ impl Parser<'_> {
t!("STRING") => Ok(Kind::String),
t!("UUID") => Ok(Kind::Uuid),
t!("RECORD") => {
let tables = match self.peek_kind() {
t!("<") => {
let next = self.next();
let mut tables = vec![self.next_token_value()?];
while self.eat(t!("|")) {
tables.push(self.next_token_value()?);
}
self.expect_closing_delimiter(t!(">"), next.span)?;
tables
let span = self.peek().span;
if self.eat(t!("<")) {
let mut tables = vec![self.next_token_value()?];
while self.eat(t!("|")) {
tables.push(self.next_token_value()?);
}
t!("(") => {
let next = self.next();
let mut tables = vec![self.next_token_value()?];
while self.eat(t!(",")) {
tables.push(self.next_token_value()?);
}
self.expect_closing_delimiter(t!(")"), next.span)?;
tables
}
_ => Vec::new(),
};
Ok(Kind::Record(tables))
self.expect_closing_delimiter(t!(">"), span)?;
Ok(Kind::Record(tables))
} else {
Ok(Kind::Record(Vec::new()))
}
}
t!("GEOMETRY") => {
let kind = match self.peek_kind() {
t!("<") => {
let delim = self.pop_peek().span;
let mut kind = vec![self.parse_geometry_kind()?];
while self.eat(t!("|")) {
kind.push(self.parse_geometry_kind()?);
}
self.expect_closing_delimiter(t!(">"), delim)?;
kind
let span = self.peek().span;
if self.eat(t!("<")) {
let mut kind = vec![self.parse_geometry_kind()?];
while self.eat(t!("|")) {
kind.push(self.parse_geometry_kind()?);
}
// Legacy gemoetry kind syntax with parens instead of `<` `>`.
t!("(") => {
let delim = self.pop_peek().span;
let mut kind = vec![self.parse_geometry_kind()?];
loop {
if self.eat(t!(")")) {
break;
}
kind.push(self.parse_geometry_kind()?);
if !self.eat(t!(",")) {
self.expect_closing_delimiter(t!(")"), delim)?;
break;
}
}
kind
}
_ => Vec::new(),
};
Ok(Kind::Geometry(kind))
self.expect_closing_delimiter(t!(">"), span)?;
Ok(Kind::Geometry(kind))
} else {
Ok(Kind::Geometry(Vec::new()))
}
}
t!("ARRAY") => {
let span = self.peek().span;

View file

@ -1922,7 +1922,7 @@ async fn select_with_record_id_link_no_index() -> Result<(), Error> {
//
let sql = "
DEFINE FIELD name ON TABLE t TYPE string;
DEFINE FIELD t ON TABLE i TYPE record(t);
DEFINE FIELD t ON TABLE i TYPE record<t>;
CREATE t:1 SET name = 'h';
CREATE t:2 SET name = 'h';
CREATE i:A SET t = t:1;
@ -1981,7 +1981,7 @@ async fn select_with_record_id_link_index() -> Result<(), Error> {
DEFINE INDEX i_t_id ON TABLE i COLUMNS t;
DEFINE INDEX t_name_idx ON TABLE t COLUMNS name;
DEFINE FIELD name ON TABLE t TYPE string;
DEFINE FIELD t ON TABLE i TYPE record(t);
DEFINE FIELD t ON TABLE i TYPE record<t>;
CREATE t:1 SET name = 'h';
CREATE t:2 SET name = 'h';
CREATE i:A SET t = t:1;
@ -2046,7 +2046,7 @@ async fn select_with_record_id_link_unique_index() -> Result<(), Error> {
DEFINE INDEX i_t_unique_id ON TABLE i COLUMNS t UNIQUE;
DEFINE INDEX t_name_idx ON TABLE t COLUMNS name;
DEFINE FIELD name ON TABLE t TYPE string;
DEFINE FIELD t ON TABLE i TYPE record(t);
DEFINE FIELD t ON TABLE i TYPE record<t>;
CREATE t:1 SET name = 'h';
CREATE t:2 SET name = 'h';
CREATE i:A SET t = t:1;
@ -2110,7 +2110,7 @@ async fn select_with_record_id_link_unique_remote_index() -> Result<(), Error> {
DEFINE INDEX i_t_id ON TABLE i COLUMNS t;
DEFINE INDEX t_name_unique_idx ON TABLE t COLUMNS name UNIQUE;
DEFINE FIELD name ON TABLE t TYPE string;
DEFINE FIELD t ON TABLE i TYPE record(t);
DEFINE FIELD t ON TABLE i TYPE record<t>;
CREATE t:1 SET name = 'a';
CREATE t:2 SET name = 'b';
CREATE i:A SET t = t:1;
@ -2179,7 +2179,7 @@ async fn select_with_record_id_link_full_text_index() -> Result<(), Error> {
DEFINE INDEX t_name_search_idx ON TABLE t COLUMNS name SEARCH ANALYZER name BM25 HIGHLIGHTS;
DEFINE INDEX i_t_id ON TABLE i COLUMNS t;
DEFINE FIELD name ON TABLE t TYPE string;
DEFINE FIELD t ON TABLE i TYPE record(t);
DEFINE FIELD t ON TABLE i TYPE record<t>;
CREATE t:1 SET name = 'Hello World';
CREATE i:A SET t = t:1;
SELECT * FROM i WHERE t.name @@ 'world' EXPLAIN;
@ -2236,7 +2236,7 @@ async fn select_with_record_id_link_full_text_no_record_index() -> Result<(), Er
DEFINE ANALYZER name TOKENIZERS class FILTERS lowercase,ngram(1,128);
DEFINE INDEX t_name_search_idx ON TABLE t COLUMNS name SEARCH ANALYZER name BM25 HIGHLIGHTS;
DEFINE FIELD name ON TABLE t TYPE string;
DEFINE FIELD t ON TABLE i TYPE record(t);
DEFINE FIELD t ON TABLE i TYPE record<t>;
CREATE t:1 SET name = 'Hello World';
CREATE i:A SET t = t:1;
SELECT * FROM i WHERE t.name @@ 'world' EXPLAIN;