Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ pub enum Expr {
/// An array index expression e.g. `(ARRAY[1, 2])[1]` or `(current_schemas(FALSE))[1]`
ArrayIndex {
obj: Box<Expr>,
indexs: Vec<Expr>,
indexes: Vec<Expr>,
},
/// An array expression e.g. `ARRAY[1, 2]`
Array(Array),
Expand Down Expand Up @@ -553,9 +553,9 @@ impl fmt::Display for Expr {
Expr::Tuple(exprs) => {
write!(f, "({})", display_comma_separated(exprs))
}
Expr::ArrayIndex { obj, indexs } => {
Expr::ArrayIndex { obj, indexes } => {
write!(f, "{}", obj)?;
for i in indexs {
for i in indexes {
write!(f, "[{}]", i)?;
}
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,15 +1234,15 @@ impl<'a> Parser<'a> {
pub fn parse_array_index(&mut self, expr: Expr) -> Result<Expr, ParserError> {
let index = self.parse_expr()?;
self.expect_token(&Token::RBracket)?;
let mut indexs: Vec<Expr> = vec![index];
let mut indexes: Vec<Expr> = vec![index];
while self.consume_token(&Token::LBracket) {
let index = self.parse_expr()?;
self.expect_token(&Token::RBracket)?;
indexs.push(index);
indexes.push(index);
}
Ok(Expr::ArrayIndex {
obj: Box::new(expr),
indexs,
indexes,
})
}

Expand Down
8 changes: 4 additions & 4 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ fn parse_array_index_expr() {
assert_eq!(
&Expr::ArrayIndex {
obj: Box::new(Expr::Identifier(Ident::new("foo"))),
indexs: vec![num[0].clone()],
indexes: vec![num[0].clone()],
},
expr_from_projection(only(&select.projection)),
);
Expand All @@ -1183,7 +1183,7 @@ fn parse_array_index_expr() {
assert_eq!(
&Expr::ArrayIndex {
obj: Box::new(Expr::Identifier(Ident::new("foo"))),
indexs: vec![num[0].clone(), num[0].clone()],
indexes: vec![num[0].clone(), num[0].clone()],
},
expr_from_projection(only(&select.projection)),
);
Expand All @@ -1193,7 +1193,7 @@ fn parse_array_index_expr() {
assert_eq!(
&Expr::ArrayIndex {
obj: Box::new(Expr::Identifier(Ident::new("bar"))),
indexs: vec![
indexes: vec![
num[0].clone(),
Expr::Identifier(Ident {
value: "baz".to_string(),
Expand Down Expand Up @@ -1224,7 +1224,7 @@ fn parse_array_index_expr() {
None
)))))
}))),
indexs: vec![num[1].clone(), num[2].clone()],
indexes: vec![num[1].clone(), num[2].clone()],
},
expr_from_projection(only(&select.projection)),
);
Expand Down