Parse UNION and EXCEPT operations (lower precedence)
(tokens: &[Token])
| 462 | |
| 463 | /// Parse UNION and EXCEPT operations (lower precedence) |
| 464 | fn parse_union_except(tokens: &[Token]) -> IResult<&[Token], Query> { |
| 465 | let (mut remaining, mut left) = parse_intersect(tokens)?; |
| 466 | |
| 467 | while let Ok((new_remaining, (operation, right))) = parse_union_except_op(remaining) { |
| 468 | left = Query::SetOperation(SetOperation { |
| 469 | left: Box::new(left), |
| 470 | operation, |
| 471 | right: Box::new(right), |
| 472 | limit_clause: None, |
| 473 | order_clause: None, |
| 474 | location: Location::default(), |
| 475 | }); |
| 476 | remaining = new_remaining; |
| 477 | } |
| 478 | |
| 479 | // Check for incomplete set operations (UNION/EXCEPT without right-hand side) |
| 480 | if !remaining.is_empty() { |
| 481 | if let Some(token) = remaining.first() { |
| 482 | match token { |
| 483 | Token::Union => { |
| 484 | return Err(nom::Err::Error(nom::error::Error::new( |
| 485 | remaining, |
| 486 | nom::error::ErrorKind::Alt, |
| 487 | ))); |
| 488 | } |
| 489 | Token::Except => { |
| 490 | return Err(nom::Err::Error(nom::error::Error::new( |
| 491 | remaining, |
| 492 | nom::error::ErrorKind::Alt, |
| 493 | ))); |
| 494 | } |
| 495 | _ => {} |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | Ok((remaining, left)) |
| 501 | } |
| 502 | |
| 503 | /// Parse INTERSECT operations (higher precedence) |
| 504 | fn parse_intersect(tokens: &[Token]) -> IResult<&[Token], Query> { |
no test coverage detected