phpmyadmin / sql-parser

A validating SQL lexer and parser with a focus on MySQL dialect.

Home Page:https://packagist.org/packages/phpmyadmin/sql-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Condition could have more detailed fields

afilina opened this issue · comments

Currently, when I parse a query, I get WHERE as Condition instances. These have an expr field, which is just a string and not very useful when analyzing a query. It would be really nice if we could be able to get more detail from that, like the operator, operands, etc.

Examples:

// c.id = 2
[
    leftOperand: ColumnReference [ column: 'id', tableAlias: 'c' ] ,
    operator: Equals []
    rightOperand: Constant [ value: 2 ]
]
// customer.address_id IS NOT NULL
[
    leftOperand: ColumnReference [ column: 'address_id', tableName: 'customer' ] ,
    operator: IsNotNull
    rightOperand: null
]

Thank you. We will work on this.