René's URL Explorer Experiment
Title: fix: traverse skipped expression children in TablesNamesFinder by AndreasLanz01 · Pull Request #2826 · JSQLParser/JSqlParser · GitHub
Open Graph Title: fix: traverse skipped expression children in TablesNamesFinder by AndreasLanz01 · Pull Request #2826 · JSQLParser/JSqlParser
X Title: fix: traverse skipped expression children in TablesNamesFinder by AndreasLanz01 · Pull Request #2826 · JSQLParser/JSqlParser
Description: What
TablesNamesFinder skipped some child expressions. A table read by a subquery in one of these positions was missing from getTables(..), getTablesOrOtherSources(..) and findTablesInExpression(..):
Node
Child that was not visited
Function
aggregate ORDER BY: string_agg(a, ',' ORDER BY ..), array_agg(a ORDER BY ..), group_concat(a ORDER BY ..); KEEP (DENSE_RANK FIRST ORDER BY ..); HAVING MAX ..; LIMIT ..; keyword arguments such as SEPARATOR ..; an attribute function: f(a).g(..)
AnalyticExpression
HAVING MAX .., LIMIT .., keyword arguments
KeepExpression
its ORDER BY (the visit was empty)
MySQLGroupConcat
all children (the visit was empty); the grammar does not create this node, so this only affects trees built through the API and has no test
LikeExpression
the ESCAPE expression
TimezoneExpression
the time zone: d AT TIME ZONE (..)
JsonExpression
operands after ->, ->>, #>, #>>
IsUnknownExpression
the operand (the visit was empty)
FullTextSearch
MATCH (..) AGAINST (..) columns and value (the visit was empty)
JsonAggregateFunction
key and value of JSON_OBJECTAGG, its ORDER BY, OVER (PARTITION BY .. ORDER BY .. ROWS ..)
TableFunction
XMLTABLE(.. PASSING ..) in FROM
Two private helpers keep this in one place: visitAggregateModifiers (KEEP, HAVING, keyword arguments and LIMIT of Function and AnalyticExpression) and visitWindowElement (window frame, moved out of visit(AnalyticExpression) and reused for JsonAggregateFunction).
visit(TableFunction) called visit(function, null), which binds at compile time to visit(Function). XmlTableFunction and JsonTableFunction extend Function, so their own visit methods were never reached. It now calls function.accept(this, context), which also passes the caller's context instead of null. JSON_TABLE is now traversed by visit(JsonTableFunction); the result is the same and is covered by a test.
Two outputs change beyond the missing tables:
MATCH (..) AGAINST (..) columns are now visited like other qualified columns: findTablesInExpression("MATCH (t.a) AGAINST ('x')") returns [t] (before: []).
An attribute column is a field name, not a column reference, so it is not visited: findTablesInExpression("f(a).b.c") returns no table.
Why
A caller that checks a statement against a table allow-list with TablesNamesFinder never saw t2 in any of these; each returned only t1, or nothing:
SELECT string_agg(a, ',' ORDER BY (SELECT max(x) FROM t2)) FROM t1
SELECT a FROM t1 WHERE a LIKE 'a' ESCAPE (SELECT max(x) FROM t2)
SELECT now() AT TIME ZONE (SELECT max(x) FROM t2)
SELECT j -> (SELECT max(x) FROM t2) FROM t1 -- Dialect.POSTGRESQL
SELECT max(a) KEEP (DENSE_RANK FIRST ORDER BY (SELECT x FROM t2)) FROM t1
SELECT a FROM t1 WHERE (SELECT x FROM t2) IS UNKNOWN
SELECT * FROM XMLTABLE('/r' PASSING (SELECT x FROM t2) COLUMNS a int PATH 'a') x
Testing
TablesNamesFinderTraversalTest:
nestedTables: 15 new cases, one per skipped child (KEEP, HAVING, LIMIT, SEPARATOR, GROUP_CONCAT ... ORDER BY, attribute function, IS UNKNOWN, MATCH ... AGAINST, the JSON aggregates, XMLTABLE), and 2 controls for JSON_TABLE and a plain table function;
new findsTablesInPostgresExpressionChildren, parsed with Dialect.POSTGRESQL, checking getTables and getTablesOrOtherSources:
8 cases for aggregate ORDER BY, ESCAPE, AT TIME ZONE and the four JSON operators;
3 cases for array subscript and slice bounds;
25 controls for positions that were already visited: function arguments, FILTER, WITHIN GROUP, window PARTITION BY / ORDER BY / frame, LIMIT / OFFSET / FETCH, ANY / ALL / SOME, ARRAY(..), VALUES, substring / trim / position / overlay, CASE, casts, GROUP BY / GROUPING SETS, DISTINCT ON, LATERAL;
expressionTables: 4 new cases through findTablesInExpression, and the f(a).b.c control;
visitsAggregateChildrenOnce: no table is visited twice.
On base bdf8ac31 the 28 cases for skipped children fail; the 3 array cases (fixed by #2749) and all controls pass.
./gradlew check on Windows 11 with the JDK 17 toolchain: 10,411 test cases, 0 failures, 0 errors, 25 skipped. Grammar ambiguity, Spotless, Checkstyle, PMD, SpotBugs and JaCoCo verification pass.
Not run: mvn verify, JMH (no grammar or parser change), Linux/macOS.
Not changed
DECLARE @x int = (SELECT ..) and PRAGMA x = (SELECT ..): their visits are empty on purpose (PRAGMA: "no tables involved").
JSON_OBJECTAGG(KEY (SELECT ..) VALUE b) does not parse, so only the VALUE position is tested.
visitBinaryExpression(BinaryExpression) still passes a null context to its children; it is public, so I left it alone.
Origin
First observed with com.manticore-projects.jsqlformatter:jsqlparser:5.4.127 and Dialect.POSTGRESQL. Reproduced on upstream master bdf8ac31bb17b2ae76400a8ddd22a39a990dcc89. The array slice upper bound, also missed in 5.4.127, is already fixed on master by #2749; this PR only adds regression tests for it. No existing issue is linked.
AI disclosure: this change was prepared with an AI coding agent (Claude Code) and reviewed by me.
Open Graph Description: What
TablesNamesFinder skipped some child expressions. A table read by a subquery in one of these positions was missing from getTables(..), getTablesOrOtherSources(..) and findTablesInExpression(.....
X Description: What
TablesNamesFinder skipped some child expressions. A table read by a subquery in one of these positions was missing from getTables(..), getTablesOrOtherSources(..) and findTablesInExpression(.....
Opengraph URL: https://github.com/JSQLParser/JSqlParser/pull/2826
X: @github
direct link
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:f030487f-ba5f-dbdd-dcc7-5d4366c33591 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E064:11BA1E:2D52E2:3CFF4F:6B04962D |
| html-safe-nonce | 7ad95ce3419129bc86a8aa2adedb0b24de8e9995cff7373c939b7a823aa25eec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDY0OjExQkExRToyRDUyRTI6M0NGRjRGOjZCMDQ5NjJEIiwidmlzaXRvcl9pZCI6IjU4ODcyNzAzNjkxNjkyODI2MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d040df177a7204a77aba6e717ae49ef2746b99a7536f6b8576d392f7d087f3d9 |
| hovercard-subject-tag | pull_request:4872563318 |
| 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 | ///pull_requests/show/files |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/JSQLParser/JSqlParser/pull/2826/files |
| twitter:image | https://avatars.githubusercontent.com/u/137876495?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/137876495?s=400&v=4 |
| og:image:alt | What
TablesNamesFinder skipped some child expressions. A table read by a subquery in one of these positions was missing from getTables(..), getTablesOrOtherSources(..) and findTablesInExpression(..... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| 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 | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Skip to content | https://github.com/JSQLParser/JSqlParser/pull/2826/files#start-of-content |
| https://github.com/ |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FJSQLParser%2FJSqlParser%2Fpull%2F2826%2Ffiles |
| GitHubRepository hosting, code review, and collaboration | https://github.com/platform |
| CopilotAI coding agent for tasks, projects, and automated work | https://github.com/features/copilot |
| ActionsCI/CD and automation | https://github.com/features/actions |
| Code QualityQuality analysis, fixes, and enforcement | https://github.com/features/code-quality |
| CodespacesCloud development environments | https://github.com/features/codespaces |
| Code SecurityVulnerability detection and remediation | https://github.com/security/advanced-security/code-security |
| Secret ProtectionSecret scanning and leak prevention | https://github.com/security/advanced-security/secret-protection |
| All Features | https://github.com/features |
| Documentation | https://docs.github.com/en |
| Training | https://learn.github.com/skills |
| Certifications | https://learn.github.com/credentials |
| Build with Copilot | https://github.com/features/ai |
| Customize Copilot | https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview |
| Integrations | https://github.com/marketplace |
| Trending repos | https://github.com/trending |
| GitHub Sponsors | https://github.com/open-source/sponsors |
| Developer articles | https://github.com/resources/articles |
| ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place. | https://github.blog/changelog/ |
| Enterprises | https://github.com/enterprise |
| Team | https://github.com/team |
| Startups | https://github.com/enterprise/startups |
| Nonprofits | https://github.com/solutions/industry/nonprofits |
| Healthcare | https://github.com/solutions/industry/healthcare |
| Financial services | https://github.com/solutions/industry/financial-services |
| Manufacturing | https://github.com/solutions/industry/manufacturing |
| Government | https://github.com/solutions/industry/government |
| See all industries | https://github.com/solutions/industry |
| Why GitHub | https://github.com/why-github |
| Customer Stories | https://github.com/customer-stories |
| Business insights | https://github.com/solutions/executive-insights |
| Trust Center | https://github.com/trust-center |
| GitHub Advanced SecurityEnterprise-grade code security | https://github.com/security/advanced-security |
| Copilot for businessEnterprise-grade AI features | https://github.com/features/copilot/copilot-business |
| Premium SupportEnterprise-grade 24/7 support | https://github.com/enterprise/premium-support |
| Documentation | https://docs.github.com/en |
| Resource center | https://github.com/resources |
| Blog | https://github.blog/ |
| Events & webinars | https://github.com/resources/events |
| Community Forum | https://github.com/orgs/community/discussions |
| Customer Stories | https://github.com/customer-stories |
| Integrations | https://github.com/marketplace |
| Customer support | https://help.github.com/ |
| Training | https://learn.github.com/skills |
| GitHub Status | https://www.githubstatus.com/ |
| About | https://github.com/about |
| Partners | https://github.com/partners |
| Changelog | https://github.blog/changelog/ |
| GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub. | https://githubuniverse.com/ |
| Pricing | https://github.com/pricing |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FJSQLParser%2FJSqlParser%2Fpull%2F2826%2Ffiles |
| Sign up | https://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 |
| Reload | https://github.com/JSQLParser/JSqlParser/pull/2826/files |
| Reload | https://github.com/JSQLParser/JSqlParser/pull/2826/files |
| Reload | https://github.com/JSQLParser/JSqlParser/pull/2826/files |
| JSQLParser | https://github.com/JSQLParser |
| JSqlParser | https://github.com/JSQLParser/JSqlParser |
| Code | https://github.com/JSQLParser/JSqlParser |
| Issues2 (2) | https://github.com/JSQLParser/JSqlParser/issues |
| Pull requests2 (2) | https://github.com/JSQLParser/JSqlParser/pulls |
| Discussions | https://github.com/JSQLParser/JSqlParser/discussions |
| Actions | https://github.com/JSQLParser/JSqlParser/actions |
| Projects | https://github.com/JSQLParser/JSqlParser/projects |
| Wiki | https://github.com/JSQLParser/JSqlParser/wiki |
| Security and quality | https://github.com/JSQLParser/JSqlParser/security |
| Insights | https://github.com/JSQLParser/JSqlParser/insights |
| Sign up for GitHub
| https://github.com/signup?return_to=%2FJSQLParser%2FJSqlParser%2Fissues%2Fnew%2Fchoose |
| terms of service | https://docs.github.com/terms |
| privacy statement | https://docs.github.com/privacy |
| Sign in | https://github.com/login?return_to=%2FJSQLParser%2FJSqlParser%2Fissues%2Fnew%2Fchoose |
| manticore-projects | https://github.com/manticore-projects |
| JSQLParser:master | https://github.com/JSQLParser/JSqlParser/tree/master |
| AndreasLanz01:fix/tables-finder-expression-positions | https://github.com/AndreasLanz01/JSqlParser/tree/fix/tables-finder-expression-positions |
|
Conversation
1
| https://github.com/JSQLParser/JSqlParser/pull/2826 |
|
Commits
1
| https://github.com/JSQLParser/JSqlParser/pull/2826/commits |
|
Checks
10
| https://github.com/JSQLParser/JSqlParser/pull/2826/checks |
|
Files changed
| https://github.com/JSQLParser/JSqlParser/pull/2826/files |
| Please reload this page | https://github.com/JSQLParser/JSqlParser/pull/2826/files |
|
fix: traverse skipped expression children in TablesNamesFinder
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#top |
|
Show all changes
1 commit
| https://github.com/JSQLParser/JSqlParser/pull/2826/files |
|
e0a233a
fix: find tables in skipped expression children
AndreasLanz01 Oct 15, 2026
| https://github.com/JSQLParser/JSqlParser/pull/2826/commits/e0a233a8dcda9a9434f64e68d8b8838fbcdf6fcc |
|
Clear filters
| https://github.com/JSQLParser/JSqlParser/pull/2826/files |
| Please reload this page | https://github.com/JSQLParser/JSqlParser/pull/2826/files |
| Please reload this page | https://github.com/JSQLParser/JSqlParser/pull/2826/files |
|
TablesNamesFinder.java
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
TablesNamesFinderTraversalTest.java
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
| src/main/java/net/sf/jsqlparser/util/TablesNamesFinder.java | https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
View file
| https://github.com/AndreasLanz01/JSqlParser/blob/e0a233a8dcda9a9434f64e68d8b8838fbcdf6fcc/src/main/java/net/sf/jsqlparser/util/TablesNamesFinder.java |
|
Open in desktop
| https://desktop.github.com |
| https://github.co/hiddenchars |
| https://github.com/JSQLParser/JSqlParser/pull/2826/{{ revealButtonHref }} |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-316573d4de546d1d0655f069706d16ecd347aad823e413ec72652511badf2294 |
| src/test/java/net/sf/jsqlparser/util/TablesNamesFinderTraversalTest.java | https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
View file
| https://github.com/AndreasLanz01/JSqlParser/blob/e0a233a8dcda9a9434f64e68d8b8838fbcdf6fcc/src/test/java/net/sf/jsqlparser/util/TablesNamesFinderTraversalTest.java |
|
Open in desktop
| https://desktop.github.com |
| https://github.co/hiddenchars |
| https://github.com/JSQLParser/JSqlParser/pull/2826/{{ revealButtonHref }} |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
|
| https://github.com/JSQLParser/JSqlParser/pull/2826/files#diff-f40cdafbff2acf49f7688d1d768c00830a5ec3e71bb4faa1b2df221d7472c485 |
| Please reload this page | https://github.com/JSQLParser/JSqlParser/pull/2826/files |
|
| https://github.com |
| Terms | https://docs.github.com/site-policy/github-terms/github-terms-of-service |
| Privacy | https://docs.github.com/site-policy/privacy-policies/github-privacy-statement |
| Security | https://github.com/security |
| Status | https://www.githubstatus.com/ |
| Community | https://github.community/ |
| Docs | https://docs.github.com/ |
| Contact | https://support.github.com?tags=dotcom-footer |
Response headers:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width
URLs of crawlers that visited me.