parseWhereClause parses "WHERE " if present. Returns nil (no error) when WHERE is absent.
()
| 422 | // parseWhereClause parses "WHERE <expr>" if present. |
| 423 | // Returns nil (no error) when WHERE is absent. |
| 424 | func (p *Parser) parseWhereClause() (ast.Expression, error) { |
| 425 | if !p.isType(models.TokenTypeWhere) { |
| 426 | return nil, nil |
| 427 | } |
| 428 | p.advance() // Consume WHERE |
| 429 | |
| 430 | // Guard against a WHERE keyword with no following expression. |
| 431 | if p.isType(models.TokenTypeEOF) || p.isType(models.TokenTypeSemicolon) || |
| 432 | p.isType(models.TokenTypeGroup) || p.isType(models.TokenTypeOrder) || |
| 433 | p.isType(models.TokenTypeLimit) || p.isType(models.TokenTypeHaving) || |
| 434 | p.isType(models.TokenTypeUnion) || p.isType(models.TokenTypeExcept) || |
| 435 | p.isType(models.TokenTypeIntersect) || p.isType(models.TokenTypeRParen) || |
| 436 | p.isType(models.TokenTypeFetch) || p.isType(models.TokenTypeFor) { |
| 437 | return nil, goerrors.ExpectedTokenError( |
| 438 | "expression after WHERE", |
| 439 | p.currentToken.Token.Type.String(), |
| 440 | p.currentLocation(), |
| 441 | "WHERE clause requires a boolean expression", |
| 442 | ) |
| 443 | } |
| 444 | |
| 445 | return p.parseExpression() |
| 446 | } |
| 447 | |
| 448 | // parseGroupByClause parses "GROUP BY <expr> [, ...]" including ROLLUP, CUBE, |
| 449 | // GROUPING SETS, and MySQL's trailing WITH ROLLUP / WITH CUBE syntax. |
no test coverage detected