mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
Fix perfstat.log columns #184
This commit is contained in:
parent
843c762dea
commit
794ea90e85
@ -242,10 +242,10 @@ public class QueryImpl<T> implements TypedQuery<T> {
|
||||
if (rebuildParser) {
|
||||
parser = queryTransformerFactory.parser(result);
|
||||
}
|
||||
String nestedEntityName = parser.getEntityNameIfSecondaryReturnedInsteadOfMain();
|
||||
String nestedEntityPath = parser.getEntityPathIfSecondaryReturnedInsteadOfMain();
|
||||
String nestedEntityName = parser.getOriginalEntityName();
|
||||
String nestedEntityPath = parser.getOriginalEntityPath();
|
||||
if (nestedEntityName != null) {
|
||||
if (parser.isCollectionSecondaryEntitySelect()) {
|
||||
if (parser.isCollectionOriginalEntitySelect()) {
|
||||
throw new IllegalStateException(String.format("Collection attributes are not supported in select clause: %s", nestedEntityPath));
|
||||
}
|
||||
QueryTransformer transformer = queryTransformerFactory.transformer(result);
|
||||
|
@ -265,74 +265,74 @@ public class QueryParserAstBasedTest {
|
||||
QueryParserAstBased parser = new QueryParserAstBased(model,
|
||||
"select h.group from sec$Constraint u, sec$GroupHierarchy h where h.userGroup = :par"
|
||||
);
|
||||
assertEquals("sec$Group", parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("h.group", parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("sec$Group", parser.getOriginalEntityName());
|
||||
assertEquals("h.group", parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select g.group from sec$GroupHierarchy h join h.group g"
|
||||
);
|
||||
assertNull(parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getOriginalEntityName());
|
||||
assertNull(parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select g from sec$GroupHierarchy h join fetch h.group g"
|
||||
);
|
||||
assertNull(parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getOriginalEntityName());
|
||||
assertNull(parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select h.parent.other from sec$GroupHierarchy h where h.userGroup = :par"
|
||||
);
|
||||
assertEquals("sec$GroupHierarchy", parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("h.parent.other", parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("sec$GroupHierarchy", parser.getOriginalEntityName());
|
||||
assertEquals("h.parent.other", parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select h.parent.other.group from sec$GroupHierarchy h where h.userGroup = :par"
|
||||
);
|
||||
assertEquals("sec$Group", parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("h.parent.other.group", parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("sec$Group", parser.getOriginalEntityName());
|
||||
assertEquals("h.parent.other.group", parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select g from sec$GroupHierarchy h join h.group g where h.userGroup = :par"
|
||||
);
|
||||
assertEquals("sec$Group", parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("g", parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("sec$Group", parser.getOriginalEntityName());
|
||||
assertEquals("g", parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select p from sec$GroupHierarchy h join h.parent p g where h.userGroup = :par"
|
||||
);
|
||||
assertEquals("sec$GroupHierarchy", parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("p", parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("sec$GroupHierarchy", parser.getOriginalEntityName());
|
||||
assertEquals("p", parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select h from sec$Constraint u, sec$GroupHierarchy h where h.userGroup = :par"
|
||||
);
|
||||
assertNull(parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getOriginalEntityName());
|
||||
assertNull(parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select h.parent.other.createdBy from sec$GroupHierarchy h where h.userGroup = :par"
|
||||
);
|
||||
assertNull(parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getOriginalEntityName());
|
||||
assertNull(parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select c from sec$GroupHierarchy h, sec$Constraint c where h.userGroup = :par"
|
||||
);
|
||||
assertNull(parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getOriginalEntityName());
|
||||
assertNull(parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select c.group from sec$GroupHierarchy h, sec$Constraint c where h.userGroup = :par"
|
||||
);
|
||||
assertEquals("sec$GroupHierarchy", parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("c.group", parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertEquals("sec$GroupHierarchy", parser.getOriginalEntityName());
|
||||
assertEquals("c.group", parser.getOriginalEntityPath());
|
||||
|
||||
parser = new QueryParserAstBased(model,
|
||||
"select u.group, u.login from sec$User u where u.name like :mask"
|
||||
);
|
||||
assertNull(parser.getEntityNameIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getEntityPathIfSecondaryReturnedInsteadOfMain());
|
||||
assertNull(parser.getOriginalEntityName());
|
||||
assertNull(parser.getOriginalEntityPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -64,7 +64,7 @@ public interface QueryParser {
|
||||
* Example: select g from sec$User u join u.group g -> sec$Group
|
||||
*/
|
||||
@Nullable
|
||||
String getEntityNameIfSecondaryReturnedInsteadOfMain();
|
||||
String getOriginalEntityName();
|
||||
|
||||
/**
|
||||
* @return Entity path if not main entity name is returned, otherwise null
|
||||
@ -72,14 +72,14 @@ public interface QueryParser {
|
||||
* Example: select g from sec$User u join u.group g -> g
|
||||
*/
|
||||
@Nullable
|
||||
String getEntityPathIfSecondaryReturnedInsteadOfMain();
|
||||
String getOriginalEntityPath();
|
||||
|
||||
/**
|
||||
* @return true if not main entity selected and it's path with collection
|
||||
* Example: select u.group from sec$User u -> false
|
||||
* Example: select u.userRoles from sec$User u -> true
|
||||
*/
|
||||
boolean isCollectionSecondaryEntitySelect();
|
||||
boolean isCollectionOriginalEntitySelect();
|
||||
|
||||
boolean isParameterInCondition(String parameterName);
|
||||
|
||||
|
@ -167,13 +167,13 @@ public class QueryParserAstBased implements QueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityNameIfSecondaryReturnedInsteadOfMain() {
|
||||
public String getOriginalEntityName() {
|
||||
EntityNameAndPath entityNameAndAlias = getEntityNameAndPathIfSecondaryReturnedInsteadOfMain();
|
||||
return entityNameAndAlias != null ? entityNameAndAlias.entityName : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityPathIfSecondaryReturnedInsteadOfMain() {
|
||||
public String getOriginalEntityPath() {
|
||||
EntityNameAndPath entityNameAndAlias = getEntityNameAndPathIfSecondaryReturnedInsteadOfMain();
|
||||
return entityNameAndAlias != null ? entityNameAndAlias.entityPath : null;
|
||||
}
|
||||
@ -191,7 +191,7 @@ public class QueryParserAstBased implements QueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollectionSecondaryEntitySelect() {
|
||||
public boolean isCollectionOriginalEntitySelect() {
|
||||
EntityNameAndPath entityNameAndAlias = getEntityNameAndPathIfSecondaryReturnedInsteadOfMain();
|
||||
return entityNameAndAlias != null && entityNameAndAlias.collectionSelect;
|
||||
}
|
||||
|
@ -151,17 +151,17 @@ public class QueryParserRegex implements QueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityNameIfSecondaryReturnedInsteadOfMain() {
|
||||
public String getOriginalEntityName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityPathIfSecondaryReturnedInsteadOfMain() {
|
||||
public String getOriginalEntityPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollectionSecondaryEntitySelect() {
|
||||
public boolean isCollectionOriginalEntitySelect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user