Details
-
Bug
-
Status: Closed
-
Resolution: Fixed
-
7.0.X, Master
-
7.0.x
-
Committed
-
5
-
3
-
Regression Bug
Description
A "concat" transformer function was introduced, for SQL Server, Oracle, DB2 and all databases logic implementations that transform the CONCAT operator, in fixpack-40 by ------------------------.LPS-75081
But one valid case throws an IllegalArgumentException. This is the full query that has stopped working:
SELECT fullNameSelect.userId, fullNameSelect.fullName, fullNameSelect.emailAddress FROM ( SELECT CONCAT ( LOWER(firstName),' ', CASE WHEN middleName != '' THEN CONCAT(LOWER(middleName),' ') ELSE '' END, LOWER(lastName) ) as fullName, userId, emailAddress FROM User_ WHERE (companyId = ?) AND (status = ?) ) AS fullNameSelect WHERE (fullName LIKE ?) OR (emailAddress LIKE ?) ORDER BY fullNameSelect.fullName
And this is the error:
java.lang.IllegalArgumentException: Unclosed string literal in: SELECT fullNameSelect.userId, fullNameSelect.fullName, fullNameSelect.emailAddress FROM (SELECT CONCAT (LOWER(firstName),' ',(CASE WHEN (middleName != '') THEN CONCAT(LOWER(middleName),' ') END) , LOWER(lastName)) as fullName, userId, emailAddress FROM User_ WHERE (companyId = 20115) AND (status = 0)) AS fullNameSelect WHERE (fullName LIKE '%Esteban%') OR (emailAddress LIKE '%Esteban%') ORDER BY fullNameSelect.fullName; at com.liferay.portal.internal.dao.sql.transformer.SQLFunctionTransformer.transform(SQLFunctionTransformer.java:100) at com.liferay.portal.dao.sql.transformer.DefaultSQLTransformer.transform(DefaultSQLTransformer.java:41) at com.liferay.portal.dao.orm.common.SQLTransformer._transformFromJPQLToHQL(SQLTransformer.java:125) at com.liferay.portal.dao.orm.common.SQLTransformer.transformFromJPQLToHQL(SQLTransformer.java:68)
According to our tests it seems that the transformer method "needs" a blank space before any argument whose first character is an apostrophe.
This is the line where the error occurs:
And it seem this line is the one to blame (the extra next++ for this case):
Also, when the transformation does not throw any exception, the transformer adds one extra blank space before the apostrophe:
CONCAT(a, 'hello') is transformed into
a + 'hello'
(note the extra space before 'hello').
Attachments
Issue Links
- is caused by
-
LPS-75081 Using CONCAT operator causes SQLException on SQL Server 2008
- Closed