mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
Merged from release_5_6 [from revision 23694]
PL-6081 NullPointerException in query transformer #PL-6081
This commit is contained in:
parent
2305a8e15f
commit
157f4056bf
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user