You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an issue with the parsing of the native SQL Queries for both the .id options and the Group by clause
Sample Code for Quick Copy:
@query(
value =
"""
SELECT v.name AS vendor_name,
COUNT(m.id) AS mould_count
FROM moulds m
LEFT JOIN vendor v ON v.id = m.converter_id
WHERE AND m.mould_code_lifecycle_stage != 'RETIRED'
AND m.mould_type = 'PRODUCTION'
AND m.id IN (SELECT unnest(allowed_moulds::bigint[])
FROM user_allowed_items
WHERE user_id = :userId)
GROUP BY v.name
ORDER BY mould_count DESC
LIMIT 5
""",
nativeQuery = true)
List<Object[]> getTopConverter(@PARAM("userId") Long userId);
Errors Thrown:
PostgreSQL: no viable alternative at input '(m' [SQL_SYNTAX]
PostgreSQL: no viable alternative at input 'GROUP' [SQL_SYNTAX]
Which STS version is this? Did you upgrade from another version and these error markers appeared?
You can workaround it by disabling SQL syntax validation in the Settings -> Spring -> Validation -> Data Queries
@Devharajan-Rangarajan you query has WHERE AND m.mould_code_lifecycle_stage != 'RETIRED' the AND after WHERE shouldn't be there I think... There is an error at unnest(allowed_moulds::bigint[]) after the AND is removed and the syntax error at :: is a bug I think.
Okay, I had an syntax error at :: in unnest(allowed_moulds::bigint[]) because I has MySql connector rather than PostgreSql. Switching to PostgreSql does not produce any syntax error. @Devharajan-Rangarajan please remove the erroneous AND as mentioned in the comment above and everything should work.
Activity
BoykoAlex commentedon Dec 18, 2024
Which STS version is this? Did you upgrade from another version and these error markers appeared?
You can workaround it by disabling SQL syntax validation in the Settings -> Spring -> Validation -> Data Queries
Devharajan-Rangarajan commentedon Dec 18, 2024
The above is the version I am using which is the latest version. I upgraded from the previous version.
Devharajan-Rangarajan commentedon Dec 18, 2024
System Details Report
Hardware Information:
Software Information:
BoykoAlex commentedon Dec 24, 2024
@Devharajan-Rangarajan you query has
WHERE AND m.mould_code_lifecycle_stage != 'RETIRED'theANDafterWHEREshouldn't be there I think... There is an error atunnest(allowed_moulds::bigint[])after theANDis removed and the syntax error at::is a bug I think.BoykoAlex commentedon Dec 24, 2024
Okay, I had an syntax error at
::inunnest(allowed_moulds::bigint[])because I has MySql connector rather than PostgreSql. Switching to PostgreSql does not produce any syntax error.@Devharajan-Rangarajan please remove the erroneous
ANDas mentioned in the comment above and everything should work.