mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 15:34:09 +00:00
feat: Allow ArrayIndex for GenericDialect (#480)
* feat: Allow ArrayIndex for GenericDialect * test array index with generic dialect too
This commit is contained in:
parent
7fc6361fe8
commit
e68bdae5f2
2 changed files with 5 additions and 5 deletions
|
@ -1173,7 +1173,7 @@ impl<'a> Parser<'a> {
|
||||||
expr: Box::new(expr),
|
expr: Box::new(expr),
|
||||||
})
|
})
|
||||||
} else if Token::LBracket == tok {
|
} else if Token::LBracket == tok {
|
||||||
if dialect_of!(self is PostgreSqlDialect) {
|
if dialect_of!(self is PostgreSqlDialect | GenericDialect) {
|
||||||
// parse index
|
// parse index
|
||||||
return self.parse_array_index(expr);
|
return self.parse_array_index(expr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ fn parse_array_index_expr() {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let sql = "SELECT foo[0] FROM foos";
|
let sql = "SELECT foo[0] FROM foos";
|
||||||
let select = pg().verified_only_select(sql);
|
let select = pg_and_generic().verified_only_select(sql);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&Expr::ArrayIndex {
|
&Expr::ArrayIndex {
|
||||||
obj: Box::new(Expr::Identifier(Ident::new("foo"))),
|
obj: Box::new(Expr::Identifier(Ident::new("foo"))),
|
||||||
|
@ -1147,7 +1147,7 @@ fn parse_array_index_expr() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let sql = "SELECT foo[0][0] FROM foos";
|
let sql = "SELECT foo[0][0] FROM foos";
|
||||||
let select = pg().verified_only_select(sql);
|
let select = pg_and_generic().verified_only_select(sql);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&Expr::ArrayIndex {
|
&Expr::ArrayIndex {
|
||||||
obj: Box::new(Expr::Identifier(Ident::new("foo"))),
|
obj: Box::new(Expr::Identifier(Ident::new("foo"))),
|
||||||
|
@ -1157,7 +1157,7 @@ fn parse_array_index_expr() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let sql = r#"SELECT bar[0]["baz"]["fooz"] FROM foos"#;
|
let sql = r#"SELECT bar[0]["baz"]["fooz"] FROM foos"#;
|
||||||
let select = pg().verified_only_select(sql);
|
let select = pg_and_generic().verified_only_select(sql);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&Expr::ArrayIndex {
|
&Expr::ArrayIndex {
|
||||||
obj: Box::new(Expr::Identifier(Ident::new("bar"))),
|
obj: Box::new(Expr::Identifier(Ident::new("bar"))),
|
||||||
|
@ -1177,7 +1177,7 @@ fn parse_array_index_expr() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let sql = "SELECT (CAST(ARRAY[ARRAY[2, 3]] AS INT[][]))[1][2]";
|
let sql = "SELECT (CAST(ARRAY[ARRAY[2, 3]] AS INT[][]))[1][2]";
|
||||||
let select = pg().verified_only_select(sql);
|
let select = pg_and_generic().verified_only_select(sql);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&Expr::ArrayIndex {
|
&Expr::ArrayIndex {
|
||||||
obj: Box::new(Expr::Nested(Box::new(Expr::Cast {
|
obj: Box::new(Expr::Nested(Box::new(Expr::Cast {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue