Title: MySQL dialect gives logical XOR the same tier as OR · Issue #2835 · JSQLParser/JSqlParser · GitHub
Open Graph Title: MySQL dialect gives logical XOR the same tier as OR · Issue #2835 · JSQLParser/JSqlParser
X Title: MySQL dialect gives logical XOR the same tier as OR · Issue #2835 · JSQLParser/JSqlParser
Description: Reproduction At current master commit f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d, compile and run this with the built JAR on the classpath: import net.sf.jsqlparser.expression.BinaryExpression; import net.sf.jsqlparser.expression.Expressio...
Open Graph Description: Reproduction At current master commit f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d, compile and run this with the built JAR on the classpath: import net.sf.jsqlparser.expression.BinaryExpression; impor...
X Description: Reproduction At current master commit f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d, compile and run this with the built JAR on the classpath: import net.sf.jsqlparser.expression.BinaryExpression; impor...
Opengraph URL: https://github.com/JSQLParser/JSqlParser/issues/2835
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MySQL dialect gives logical XOR the same tier as OR","articleBody":"## Reproduction\n\nAt current `master` commit `f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d`, compile and run this with the built JAR on the classpath:\n\n```java\nimport net.sf.jsqlparser.expression.BinaryExpression;\nimport net.sf.jsqlparser.expression.Expression;\nimport net.sf.jsqlparser.parser.AbstractJSqlParser.Dialect;\nimport net.sf.jsqlparser.parser.CCJSqlParserUtil;\nimport net.sf.jsqlparser.statement.select.Select;\npublic class Repro {\n static void show(Expression e, String prefix) {\n System.out.println(prefix + e.getClass().getSimpleName() + \": \" + e);\n if (e instanceof BinaryExpression b) {\n show(b.getLeftExpression(), prefix + \" L \");\n show(b.getRightExpression(), prefix + \" R \");\n }\n }\n public static void main(String[] args) throws Exception {\n for (String x : new String[]{\"1 OR 1 XOR 1\", \"1 OR (1 XOR 1)\"}) {\n Select s = (Select) CCJSqlParserUtil.parse(\"SELECT \" + x + \" AS x\",\n p -> p.withDialect(Dialect.MYSQL));\n System.out.println(\"INPUT \" + x);\n show(s.getPlainSelect().getSelectItem(0).getExpression(), \"\");\n }\n }\n}\n```\n\nObserved 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](https://dev.mysql.com/doc/refman/8.4/en/operator-precedence.html), 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.\n\nThe [boolean parser loop](https://github.com/JSQLParser/JSqlParser/blob/f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt#L689-L728) 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](https://github.com/JSQLParser/JSqlParser/issues/1070) concerns OR/AND; [#2834](https://github.com/JSQLParser/JSqlParser/issues/2834) concerns a separate arithmetic/bitwise parser loop.\n","author":{"url":"https://github.com/pbottine","@type":"Person","name":"pbottine"},"datePublished":"2026-10-20T01:12:23Z","url":"https://github.com/JSQLParser/JSqlParser/issues/2835"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8d365325-88c3-c240-ee2f-5049d20eb526 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DDF8:12691F:55B4A1:7350BA:6B043DCA |
| html-safe-nonce | c6b81ac8657324ea13493392ec3852ad5c0809e9a1b5888c904a67b557d8bbd7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREY4OjEyNjkxRjo1NUI0QTE6NzM1MEJBOjZCMDQzRENBIiwidmlzaXRvcl9pZCI6Ijg3NzMwMjA1NTg0NzM1NzU4ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2b64772fd07a585841e93dbfea095723d0aaafa72557c3a4eca6bdfdbf5a2409 |
| hovercard-subject-tag | issue:5934165681 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JSQLParser/JSqlParser/2835/issue_layout |
| twitter:image | https://opengraph.githubassets.com/be81d69fb19304e189505bb2f44de24fa2b09bfa6e7a09690659b82169cb5c18/JSQLParser/JSqlParser/issues/2835 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/be81d69fb19304e189505bb2f44de24fa2b09bfa6e7a09690659b82169cb5c18/JSQLParser/JSqlParser/issues/2835 |
| og:image:alt | Reproduction At current master commit f6ac2571e6e9777d6a5ee942a4ea53cd91153e4d, compile and run this with the built JAR on the classpath: import net.sf.jsqlparser.expression.BinaryExpression; impor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pbottine |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/JSQLParser/JSqlParser git https://github.com/JSQLParser/JSqlParser.git |
| octolytics-dimension-user_id | 4643847 |
| octolytics-dimension-user_login | JSQLParser |
| octolytics-dimension-repository_id | 1944709 |
| octolytics-dimension-repository_nwo | JSQLParser/JSqlParser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1944709 |
| octolytics-dimension-repository_network_root_nwo | JSQLParser/JSqlParser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width