diff --git a/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java b/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java index 9e4d19a12f..fa2139bb38 100644 --- a/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java +++ b/modules/core/test/com/haulmont/cuba/core/global/QueryTransformerRegexTest.java @@ -376,4 +376,12 @@ public class QueryTransformerRegexTest extends TestCase { "SELECT distinct h.level from sec$Constraint u, sec$GroupHierarchy h join h.parent.constraints c where h.userGroup = :par", res); } + + public void testNpeInReplaceOrderBy() { + QueryTransformerRegex transformer = new QueryTransformerRegex( + "select drB from taxi$DriverBan drB where drB.driver.id = :ds_driverDs order by drB.from"); + String[] properties = new String[]{"driver.name", "driver.callsignName"}; + + transformer.replaceOrderBy(true, properties); + } } diff --git a/modules/global/src/com/haulmont/cuba/core/global/QueryParserRegex.java b/modules/global/src/com/haulmont/cuba/core/global/QueryParserRegex.java index a311fb8a42..a024f51224 100644 --- a/modules/global/src/com/haulmont/cuba/core/global/QueryParserRegex.java +++ b/modules/global/src/com/haulmont/cuba/core/global/QueryParserRegex.java @@ -23,7 +23,7 @@ public class QueryParserRegex implements QueryParser { public static final int QS_ALIAS = 2; public static final String ENTITY_PATTERN_REGEX = "(\\b[_A-Za-z]+\\$[A-Z][_A-Za-z0-9]*)(\\s+as\\b)?\\s+([a-z]+[a-z0-9]*)*\\b"; - public static final Pattern ENTITY_PATTERN = Pattern.compile(ENTITY_PATTERN_REGEX); + public static final Pattern ENTITY_PATTERN = Pattern.compile(ENTITY_PATTERN_REGEX, Pattern.CASE_INSENSITIVE); public static final int EP_ALIAS = 3; public static final Pattern FROM_ENTITY_PATTERN = Pattern.compile("\\b(from|update)\\s+" + ENTITY_PATTERN_REGEX, Pattern.CASE_INSENSITIVE); diff --git a/modules/global/src/com/haulmont/cuba/core/global/QueryTransformerRegex.java b/modules/global/src/com/haulmont/cuba/core/global/QueryTransformerRegex.java index 21269718ea..aeed28870e 100644 --- a/modules/global/src/com/haulmont/cuba/core/global/QueryTransformerRegex.java +++ b/modules/global/src/com/haulmont/cuba/core/global/QueryTransformerRegex.java @@ -347,7 +347,7 @@ public class QueryTransformerRegex extends QueryParserRegex implements QueryTran String alias = null; while (entityMatcher.find()) { String matchedAlias = entityMatcher.group(EP_ALIAS); - if (matchedAlias.equalsIgnoreCase(firstAlias)) { + if (matchedAlias != null && matchedAlias.equalsIgnoreCase(firstAlias)) { alias = matchedAlias; break; }