|
18 | 18 | mod test_utils;
|
19 | 19 | use test_utils::*;
|
20 | 20 |
|
21 |
| -use sqlparser::ast::FunctionArg::Unnamed; |
22 |
| -use sqlparser::ast::Value::Number; |
23 | 21 | use sqlparser::ast::*;
|
24 | 22 | use sqlparser::dialect::{GenericDialect, PostgreSqlDialect};
|
25 | 23 | use sqlparser::parser::ParserError;
|
@@ -3881,7 +3879,8 @@ fn parse_join_constraint_unnest_alias() {
|
3881 | 3879 | Ident::new("a")
|
3882 | 3880 | ])],
|
3883 | 3881 | with_offset: false,
|
3884 |
| - with_offset_alias: None |
| 3882 | + with_offset_alias: None, |
| 3883 | + with_ordinality: false, |
3885 | 3884 | },
|
3886 | 3885 | join_operator: JoinOperator::Inner(JoinConstraint::On(Expr::BinaryOp {
|
3887 | 3886 | left: Box::new(Expr::Identifier("c1".into())),
|
@@ -4189,37 +4188,33 @@ fn parse_create_table_with_options() {
|
4189 | 4188 |
|
4190 | 4189 | #[test]
|
4191 | 4190 | fn test_table_function_with_ordinality() {
|
4192 |
| - let sql = "SELECT * FROM generate_series(1, 10) WITH ORDINALITY AS t"; |
4193 |
| - match pg_and_generic().verified_stmt(sql) { |
4194 |
| - Statement::Query(query) => { |
4195 |
| - assert_eq!( |
4196 |
| - query.body.as_select().unwrap().from, |
4197 |
| - vec![TableWithJoins { |
4198 |
| - relation: TableFactor::Table { |
4199 |
| - name: ObjectName(vec![Ident::new("generate_series")]), |
4200 |
| - args: Some(vec![ |
4201 |
| - Unnamed(FunctionArgExpr::Expr(Expr::Value(Number( |
4202 |
| - "1".parse().unwrap(), |
4203 |
| - false |
4204 |
| - )))), |
4205 |
| - Unnamed(FunctionArgExpr::Expr(Expr::Value(Number( |
4206 |
| - "10".parse().unwrap(), |
4207 |
| - false |
4208 |
| - )))), |
4209 |
| - ]), |
4210 |
| - alias: Some(TableAlias { |
4211 |
| - name: Ident::new("t"), |
4212 |
| - columns: vec![], |
4213 |
| - }), |
4214 |
| - with_hints: vec![], |
4215 |
| - version: None, |
4216 |
| - partitions: vec![], |
4217 |
| - with_ordinality: true, |
4218 |
| - }, |
4219 |
| - joins: vec![], |
4220 |
| - }] |
4221 |
| - ); |
| 4191 | + let from = pg_and_generic() |
| 4192 | + .verified_only_select("SELECT * FROM generate_series(1, 10) WITH ORDINALITY AS t") |
| 4193 | + .from; |
| 4194 | + assert_eq!(1, from.len()); |
| 4195 | + match from[0].relation { |
| 4196 | + TableFactor::Table { |
| 4197 | + ref name, |
| 4198 | + with_ordinality: true, |
| 4199 | + .. |
| 4200 | + } => { |
| 4201 | + assert_eq!("generate_series", name.to_string().as_str()); |
4222 | 4202 | }
|
4223 |
| - _ => unreachable!(), |
| 4203 | + _ => panic!("Expecting TableFactor::Table with ordinality"), |
| 4204 | + } |
| 4205 | +} |
| 4206 | + |
| 4207 | +#[test] |
| 4208 | +fn test_table_unnest_with_ordinality() { |
| 4209 | + let from = pg_and_generic() |
| 4210 | + .verified_only_select("SELECT * FROM UNNEST([10, 20, 30]) WITH ORDINALITY AS t") |
| 4211 | + .from; |
| 4212 | + assert_eq!(1, from.len()); |
| 4213 | + match from[0].relation { |
| 4214 | + TableFactor::UNNEST { |
| 4215 | + with_ordinality: true, |
| 4216 | + .. |
| 4217 | + } => {} |
| 4218 | + _ => panic!("Expecting TableFactor::UNNEST with ordinality"), |
4224 | 4219 | }
|
4225 | 4220 | }
|
0 commit comments