-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram
Failing SQL Feature:
- A combination of POSITION IN and nested functions seem to confuse the parser
SQL Example:
- Simplified Query Example, focusing on the failing feature
SELECT
POSITION(' ' IN my_column) > 0,
SUBSTRING(FOO_FUNCTION(my_column, ''), 1)
FROM my_table
Software Information:
- JSqlParser 5.4 SNAPSHOT (pulled from master branch on 2025-09-15, commit 9dfa0d6)
- PostgreSQL
More Information:
This is a weird issue, and seems to involve interplay between the 'POSITION IN' syntax in Postgres, when combined with nested functions. In the example SQL, it fails to parse; however if I remove either the 'POSITION IN' select item or remove FOO_FUNCTION (and replace the entire function call with a column name), it works. For instance, both of these modifications will parse properly:
SELECT
SUBSTRING(FOO_FUNCTION(my_column, ''), 1)
FROM my_table
SELECT
POSITION(' ' IN my_column) > 0,
SUBSTRING(my_column, 1)
FROM my_table
The problem SQL as shown at the top works in JSQLParser 4.5 (the version that we currently use in our production software).
Trying the same SQL in the formatter results in the same error. See http://jsqlformatter.manticore-projects.com/jsqlformatter/demo.html?args=-c%20LTAEDMEMEsBsFMAmoAuB7CaBOBbSLQBnFSLFAKAGUBRAGWoGEAVUc0d0ABQHlKBJJn24A5ABQByUJL7DQOAJ4B9AMZpYAVxwA7AJSgAfKAAMAGjYdKAVQBClJgCUZAcVEAxbt0WvLw5kLEKKmqaWiZS4jphAIx65K723ACyckokAEYI5CAQMAjI6Ji4+KDwWohAA .
When using JSQLParser 5.3 I also get an error, although the error is different from what I see in 5.4 SNAPSHOT.