You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MySQL dialect gives logical XOR the same tier as OR #2835
At current master commit f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d, compile and run this with the built JAR on the classpath:
importnet.sf.jsqlparser.expression.BinaryExpression;
importnet.sf.jsqlparser.expression.Expression;
importnet.sf.jsqlparser.parser.AbstractJSqlParser.Dialect;
importnet.sf.jsqlparser.parser.CCJSqlParserUtil;
importnet.sf.jsqlparser.statement.select.Select;
publicclassRepro {
staticvoidshow(Expressione, Stringprefix) {
System.out.println(prefix + e.getClass().getSimpleName() + ": " + e);
if (einstanceofBinaryExpressionb) {
show(b.getLeftExpression(), prefix + " L ");
show(b.getRightExpression(), prefix + " R ");
}
}
publicstaticvoidmain(String[] args) throwsException {
for (Stringx : newString[]{"1 OR 1 XOR 1", "1 OR (1 XOR 1)"}) {
Selects = (Select) CCJSqlParserUtil.parse("SELECT " + x + " AS x",
p -> p.withDialect(Dialect.MYSQL));
System.out.println("INPUT " + x);
show(s.getPlainSelect().getSelectItem(0).getExpression(), "");
}
}
}
Observed on 2026-10-19: unparenthesized input has a XorExpression root with OrExpression(1, 1) on the left. The parenthesized control has an OrExpression root. MySQL puts logical XOR above OR, so the unparenthesized input should also have an OR root: 1 OR (1 XOR 1) evaluates to true, whereas (1 OR 1) XOR 1 evaluates to false.
The boolean parser loop comments that XOR should have precedence 3 and OR precedence 2, but assigns both the value 2. The resulting AST groups them left-to-right. #1070 concerns OR/AND; #2834 concerns a separate arithmetic/bitwise parser loop.
Activity
Match MySQL operator precedence for XOR and bitwise operators (JSQLPa…