Parse WITH clause: WITH [DISTINCT|ALL] expr [AS alias] [, expr [AS alias]]* [WHERE condition] [ORDER BY ...] [LIMIT ...]
(tokens: &[Token])
| 1429 | |
| 1430 | /// Parse WITH clause: WITH [DISTINCT|ALL] expr [AS alias] [, expr [AS alias]]* [WHERE condition] [ORDER BY ...] [LIMIT ...] |
| 1431 | fn with_clause(tokens: &[Token]) -> IResult<&[Token], WithClause> { |
| 1432 | map( |
| 1433 | tuple(( |
| 1434 | expect_token(Token::With), |
| 1435 | opt(alt(( |
| 1436 | value(DistinctQualifier::Distinct, expect_token(Token::Distinct)), |
| 1437 | value(DistinctQualifier::All, expect_token(Token::All)), |
| 1438 | ))), |
| 1439 | with_item, |
| 1440 | many0(tuple((expect_token(Token::Comma), with_item))), |
| 1441 | opt(where_clause), |
| 1442 | opt(order_clause), |
| 1443 | opt(limit_clause), |
| 1444 | )), |
| 1445 | |(_, distinct_opt, first, rest, where_clause, order_clause, limit_clause)| { |
| 1446 | let mut items = vec![first]; |
| 1447 | items.extend(rest.into_iter().map(|(_, item)| item)); |
| 1448 | WithClause { |
| 1449 | distinct: distinct_opt.unwrap_or(DistinctQualifier::None), |
| 1450 | items, |
| 1451 | where_clause, |
| 1452 | order_clause, |
| 1453 | limit_clause, |
| 1454 | location: Location::default(), |
| 1455 | } |
| 1456 | }, |
| 1457 | )(tokens) |
| 1458 | } |
| 1459 | |
| 1460 | /// Parse WITH item: expression [AS alias] |
| 1461 | fn with_item(tokens: &[Token]) -> IResult<&[Token], WithItem> { |
nothing calls this directly
no test coverage detected