René's URL Explorer Experiment


Title: fix: parse CASE with a signed switch value by ybai08 · Pull Request #2869 · JSQLParser/JSqlParser · GitHub

Open Graph Title: fix: parse CASE with a signed switch value by ybai08 · Pull Request #2869 · JSQLParser/JSqlParser

X Title: fix: parse CASE with a signed switch value by ybai08 · Pull Request #2869 · JSQLParser/JSqlParser

Description: A simple CASE whose switch value starts with - or + no longer parses: Input master SELECT CASE -1 WHEN -1 THEN 'x' END FROM t ParseException SELECT CASE -a WHEN 1 THEN 2 END FROM t ParseException CCJSqlParserUtil.parseExpression("CASE -a WHEN 1 THEN 2 END") returns case - a (a Subtraction on a column named case); the rest is dropped CASE ~1 WHEN …, CASE (-1) WHEN … and CASE 0 - 1 WHEN … parse. SQL allows any value expression as the CASE operand, and SQLite evaluates these statements. The cause is isCaseExpressionAhead, added in the Pratt rewrite (365078d) in place of LOOKAHEAD(3) on CaseWhenExpression(). It treats CASE followed by + or - as a column named case, so that SELECT case - 1 FROM t parses. With this change, when + or - follows CASE, a new helper isWhenAheadOfCaseOperand walks the token chain (nextWithItemToken, like the other lookahead helpers). It answers "CASE expression" if a WHEN comes before the expression ends, skipping brackets and nested CASE … END. It answers "column" at ), END, THEN, ELSE, FROM, WHERE, ,, ; or EOF at the same level. So case - 1, case + 1, case - CASE WHEN a THEN 1 END and case - (CASE a WHEN 1 THEN 2 END) still parse as a binary expression on a column named case. Only CASE followed by a sign goes through the walk, and it stops at the first token that ends the expression. Tests (CaseExpressionTest): testSignedSwitchExpression: 7 expressions (-1, -a, +a, -a + b, -t.a, -abs(a), -(a) as the switch value). Each must round-trip and parse to a CaseExpression with that switch expression. All 7 fail on master c84ad0eb (expected: but was: , etc.). testCaseColumnFollowedBySign: the 4 column forms above, which must still give a BinaryExpression. They pass on master and with the change. What was run (Gradle with a JDK 17 toolchain): ./gradlew test --tests CaseExpressionTest: 28 tests, 7 failed without the grammar change, 0 failed with it. ./gradlew check: BUILD SUCCESSFUL. 12,273 tests, 0 failures, 25 skipped. Spotless, Checkstyle, PMD, SpotBugs and JaCoCo also pass. A differential check against SQLite (Python sqlite3). 20,000 random SELECT FROM t statements using arithmetic, bitwise, comparison, LIKE/GLOB, BETWEEN, IN, IS [NOT] NULL, CASE, CAST and a few functions were parsed and deparsed with JSqlParser. SQLite evaluated both the original and the deparsed SQL. On master, 0 results differ, and 43 statements that SQLite accepts fail to parse because of a signed CASE switch value. With this change, those 43 parse and their deparsed SQL gives the same result in SQLite. No statement that parsed on master fails now, and 0 results differ. Not run: gradle jmh.

Open Graph Description: A simple CASE whose switch value starts with - or + no longer parses: Input master SELECT CASE -1 WHEN -1 THEN 'x' END FROM t ParseException SELECT CASE -a WHEN 1 THEN 2 END FROM t...

X Description: A simple CASE whose switch value starts with - or + no longer parses: Input master SELECT CASE -1 WHEN -1 THEN 'x' END FROM t ParseException SELECT CASE -a WHEN 1 THEN 2 EN...

Opengraph URL: https://github.com/JSQLParser/JSqlParser/pull/2869

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.3

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:b2560495-4cb8-ea42-2712-ec983d5b79d1
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDDC2:1F2F:76BBC8:A07260:6B04400D
html-safe-nonce8e3d6cf0a4b123dacda0ad9dd0c76c4202192d6869e3d6f8e4df5e731dd0c5a6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREMyOjFGMkY6NzZCQkM4OkEwNzI2MDo2QjA0NDAwRCIsInZpc2l0b3JfaWQiOiI1Mjg1OTI0OTc0NzYzODY4MjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac8154fb31388523fd582610919ce8c3e327ec52e1506c7122f51dab578ab7ce66
hovercard-subject-tagpull_request:5050666891
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/JSQLParser/JSqlParser/pull/2869/files
twitter:imagehttps://avatars.githubusercontent.com/u/271969568?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/271969568?s=400&v=4
og:image:altA simple CASE whose switch value starts with - or + no longer parses: Input master SELECT CASE -1 WHEN -1 THEN 'x' END FROM t ParseException SELECT CASE -a WHEN 1 THEN 2 END FROM t...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/JSQLParser/JSqlParser git https://github.com/JSQLParser/JSqlParser.git
octolytics-dimension-user_id4643847
octolytics-dimension-user_loginJSQLParser
octolytics-dimension-repository_id1944709
octolytics-dimension-repository_nwoJSQLParser/JSqlParser
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1944709
octolytics-dimension-repository_network_root_nwoJSQLParser/JSqlParser
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release06dc448a76fe4751ac1db26524aefa3aa3e889a8
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/JSQLParser/JSqlParser/pull/2869/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FJSQLParser%2FJSqlParser%2Fpull%2F2869%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FJSQLParser%2FJSqlParser%2Fpull%2F2869%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=JSQLParser%2FJSqlParser
Reloadhttps://github.com/JSQLParser/JSqlParser/pull/2869/files
Reloadhttps://github.com/JSQLParser/JSqlParser/pull/2869/files
Reloadhttps://github.com/JSQLParser/JSqlParser/pull/2869/files
JSQLParserhttps://github.com/JSQLParser
JSqlParserhttps://github.com/JSQLParser/JSqlParser
Codehttps://github.com/JSQLParser/JSqlParser
Issues2 (2)https://github.com/JSQLParser/JSqlParser/issues
Pull requests2 (2)https://github.com/JSQLParser/JSqlParser/pulls
Discussionshttps://github.com/JSQLParser/JSqlParser/discussions
Actionshttps://github.com/JSQLParser/JSqlParser/actions
Projectshttps://github.com/JSQLParser/JSqlParser/projects
Wikihttps://github.com/JSQLParser/JSqlParser/wiki
Security and qualityhttps://github.com/JSQLParser/JSqlParser/security
Insightshttps://github.com/JSQLParser/JSqlParser/insights
Sign up for GitHub https://github.com/signup?return_to=%2FJSQLParser%2FJSqlParser%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FJSQLParser%2FJSqlParser%2Fissues%2Fnew%2Fchoose
ybai08https://github.com/ybai08
JSQLParser:masterhttps://github.com/JSQLParser/JSqlParser/tree/master
ybai08:fix/case-signed-switchhttps://github.com/ybai08/JSqlParser/tree/fix/case-signed-switch
Conversation 0 https://github.com/JSQLParser/JSqlParser/pull/2869
Commits 1 https://github.com/JSQLParser/JSqlParser/pull/2869/commits
Checks 10 https://github.com/JSQLParser/JSqlParser/pull/2869/checks
Files changed https://github.com/JSQLParser/JSqlParser/pull/2869/files
Please reload this pagehttps://github.com/JSQLParser/JSqlParser/pull/2869/files
fix: parse CASE with a signed switch value https://github.com/JSQLParser/JSqlParser/pull/2869/files#top
Show all changes 1 commit https://github.com/JSQLParser/JSqlParser/pull/2869/files
9fe66c0 fix: parse CASE with a signed switch value ybai08 Oct 28, 2026 https://github.com/JSQLParser/JSqlParser/pull/2869/commits/9fe66c0098c08b1cbf5a7f59323666e0ec28aee5
Clear filters https://github.com/JSQLParser/JSqlParser/pull/2869/files
Please reload this pagehttps://github.com/JSQLParser/JSqlParser/pull/2869/files
Please reload this pagehttps://github.com/JSQLParser/JSqlParser/pull/2869/files
JSqlParserCC.jjt https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-d323df58a0300a038ac87b328bf05b8255ff06e6b5d0e9aeae641fa566e4068c
CaseExpressionTest.java https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-a4069608ca6c559a4cdf22518de871c08ef1ac15d5d586b49bcc10d843258747
src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjthttps://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-d323df58a0300a038ac87b328bf05b8255ff06e6b5d0e9aeae641fa566e4068c
View file https://github.com/JSQLParser/JSqlParser/blob/9fe66c0098c08b1cbf5a7f59323666e0ec28aee5/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/JSQLParser/JSqlParser/pull/2869/{{ revealButtonHref }}
https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-d323df58a0300a038ac87b328bf05b8255ff06e6b5d0e9aeae641fa566e4068c
https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-d323df58a0300a038ac87b328bf05b8255ff06e6b5d0e9aeae641fa566e4068c
https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-d323df58a0300a038ac87b328bf05b8255ff06e6b5d0e9aeae641fa566e4068c
src/test/java/net/sf/jsqlparser/expression/CaseExpressionTest.javahttps://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-a4069608ca6c559a4cdf22518de871c08ef1ac15d5d586b49bcc10d843258747
View file https://github.com/JSQLParser/JSqlParser/blob/9fe66c0098c08b1cbf5a7f59323666e0ec28aee5/src/test/java/net/sf/jsqlparser/expression/CaseExpressionTest.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/JSQLParser/JSqlParser/pull/2869/{{ revealButtonHref }}
https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-a4069608ca6c559a4cdf22518de871c08ef1ac15d5d586b49bcc10d843258747
https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-a4069608ca6c559a4cdf22518de871c08ef1ac15d5d586b49bcc10d843258747
https://github.com/JSQLParser/JSqlParser/pull/2869/files#diff-a4069608ca6c559a4cdf22518de871c08ef1ac15d5d586b49bcc10d843258747
Please reload this pagehttps://github.com/JSQLParser/JSqlParser/pull/2869/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.