Open
Description
Database Type
MySQL
Database Version
MySQL 5.7
Druid Version
1.2.23/1.2.24
JDK Version
Jdk1.8
Error SQL
使用SQLBinaryOpExpr生成(5 + 3) / 2表达式,生成的结果中缺失括号,导致SQL执行结果与预期完全不符
Testcase Code
// 加法表达式 5+3
SQLBinaryOpExpr addExpr = new SQLBinaryOpExpr();
addExpr.setLeft(new SQLIntegerExpr(5));
addExpr.setOperator(SQLBinaryOperator.Add);
addExpr.setRight(new SQLIntegerExpr(3));
//除法表达式 (5 + 3) / 2
SQLBinaryOpExpr deviceExpr = new SQLBinaryOpExpr();
deviceExpr.setLeft(addExpr);
deviceExpr.setOperator(SQLBinaryOperator.Divide);
deviceExpr.setRight(new SQLIntegerExpr(2));
// 期望输出(5 + 3) / 2,实际输出为 5 + 3 / 2
System.out.println(deviceExpr);
实际生成的SQLBinaryOpExpr 中缺少了括号,导致SQL含义发生了变化,执行结果不符合预期
Stacktrace Info
No response
Error Info
在数据库执行生成的SQLBinaryOpExpr表达式时,和预期不符
Metadata
Metadata
Assignees
Labels
No labels