taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
798 stars 180 forks source link

Change the type definition of `Cast.expr` from `Expr` to `ExpressionValue` #1987

Closed LYP951018 closed 3 months ago

LYP951018 commented 3 months ago

It appears that Expr represents a binary expression used in a condition, and in the Cast node, it seems more appropriate to use ExpressionValue instead of Expr.

I dump the AST and found that the expr in the Cast node is indeed ExpressionValue not Expr:

"expr": {
    "type": "cast",
    "keyword": "cast",
    "expr": {
        "type": "column_ref",
        "table": null,
        "column": "out_trade_no_"
    },
    "symbol": "as",
    "target": {
        "dataType": "INTEGER",
        "suffix": []
    }
},
taozhi8833998 commented 3 months ago

@LYP951018 Thanks for the pr, merged it.