Title: Lex MySQL backslash escapes consistently in string literals by minleejae · Pull Request #2790 · JSQLParser/JSqlParser · GitHub
Open Graph Title: Lex MySQL backslash escapes consistently in string literals by minleejae · Pull Request #2790 · JSQLParser/JSqlParser
X Title: Lex MySQL backslash escapes consistently in string literals by minleejae · Pull Request #2790 · JSQLParser/JSqlParser
Description: Purpose Lex string literals with backslash escapes the way MySQL reads them. This applies with Dialect.MYSQL, Dialect.MARIADB or withBackslashEscapeCharacter(true). Today: SELECT 'it\'s ''x''' FROM t silently splits into the string 'it\'s ' and an alias 'x'''. 'a\0b\'c', '\Z\'', 'a''b\'c' and 'x\%\'y' fail with a lexical error. The double-quoted "it\"s" fails as well. MySQL 8.4, MySQL 8.0 and MariaDB 11.4 read each of these as a single string. Current design (As-is) Single-quoted literals have two pattern alternatives: a backslash-aware one that knows only \n \t \b \r \f \\ \" \' and no doubled quote; a plain one without backslash escapes. The token action patches the longest match with \'/\'' heuristics. Double-quoted strings reuse the quoted-identifier token, which has no backslash escapes. Target design (To-be) Let the backslash-aware alternatives of both quote styles read any escaped character and doubled quotes. In the token action, trim the match to the closing quote under the rules in effect. One helper serves both quote styles: A backslash escapes the next character only when backslash escapes are enabled, or in a PostgreSQL E'' string. Otherwise the literal ends at the first quote that is not doubled. These keep their previous tokens: standard strings, LIKE ... ESCAPE '\', Oracle q'...' literals, and quoted identifiers such as "col\". Validation New tests cover: mixed escapes in MySQL; PostgreSQL E'' and standard strings; the unchanged default reading; double-quoted strings in the MySQL, MariaDB, BigQuery and Databricks presets; each feature switch alone and both together; quoted identifiers. Java 17 offline Gradle spotlessApply check: 10,096 tests, 10,071 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes. The full suite also passes unchanged against the reworked tokens. Ran 32 statements on MySQL 8.4, MySQL 8.0, MariaDB 11.4 and PostgreSQL 18.3, in original and rendered form. All succeed both ways. "a\""b", which MySQL rejects, is rejected by the parser too. Integration validation Applied #2788, #2789, #2790, #2791 and #2792 together on master (166f0a27): Every pair merges without conflicts, and the combined grammar is free of choice conflicts. The integrated build passes Java 17 offline Gradle spotlessApply check: 10,150 tests, 10,125 passed, 25 skipped, zero failures/errors. With the integrated build, the same server results hold on MySQL 8.4, MySQL 8.0, MariaDB 11.4 and PostgreSQL 18.3: the 95 statement cases of these PRs; the 11 default-mode drop cases; 51 string literal comparisons, including 16 mixed-escape literals that need #2790 and #2791 together.
Open Graph Description: Purpose Lex string literals with backslash escapes the way MySQL reads them. This applies with Dialect.MYSQL, Dialect.MARIADB or withBackslashEscapeCharacter(true). Today: SELECT 'it\'s ...
X Description: Purpose Lex string literals with backslash escapes the way MySQL reads them. This applies with Dialect.MYSQL, Dialect.MARIADB or withBackslashEscapeCharacter(true). Today: SELECT 'it\&...
Opengraph URL: https://github.com/JSQLParser/JSqlParser/pull/2790
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b797c399-5323-fe5c-2fef-31104ae975ca |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BA3E:355C02:228B8D:2ECC4A:6B0493CB |
| html-safe-nonce | ffedf942eef35f22cf3d3e2c2ef4fbbae647eab052d8dc7259baaa05eba67b8d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTNFOjM1NUMwMjoyMjhCOEQ6MkVDQzRBOjZCMDQ5M0NCIiwidmlzaXRvcl9pZCI6IjY2NzY0ODg1NzEzNjI1MTM4NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3ac6fd5c66d90721f89434a32556549e213a97e769d2e4d5e07eface9f9d2948 |
| hovercard-subject-tag | pull_request:4838501412 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/JSQLParser/JSqlParser/pull/2790/files |
| twitter:image | https://avatars.githubusercontent.com/u/55116920?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/55116920?s=400&v=4 |
| og:image:alt | Purpose Lex string literals with backslash escapes the way MySQL reads them. This applies with Dialect.MYSQL, Dialect.MARIADB or withBackslashEscapeCharacter(true). Today: SELECT 'it\'s ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b297275a74a2c9a35898175c9477837c635d4f579277ebff3b2d6ebd012e247 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b51ce57ca6d4565a42856fc1c9897077c794597f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width