DaanHoogland commented on code in PR #7169:
URL: https://github.com/apache/cloudstack/pull/7169#discussion_r1098241331
##########
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java:
##########
@@ -617,7 +618,9 @@ private Pair<List<UserAccountJoinVO>, Integer>
getUserListInternal(Account calle
ssc.addOr("email", Op.LIKE, "%" + keyword + "%");
ssc.addOr("state", Op.LIKE, "%" + keyword + "%");
ssc.addOr("accountName", Op.LIKE, "%" + keyword + "%");
- ssc.addOr("accountType", Op.LIKE, "%" + keyword + "%");
+ if (EnumUtils.isValidEnum(Account.Type.class,
keyword.toString().toUpperCase())) {
+ ssc.addOr("accountType", Op.EQ,
EnumUtils.getEnum(Account.Type.class, keyword.toString().toUpperCase()));
+ }
Review Comment:
no, but a `toUpperCase()` can be added, and still the `toString()` can be
dropped. It will return null if no value is found. I.E.
```suggestion
try {
if (Account.Type.valueOf(keyword.toUpperCase())) {
ssc.addOr("accountType", Op.EQ,
EnumUtils.getEnum(Account.Type.class, keyword.toUpperCase()));
}
} catch ([IllegalArgumentException e) {
logger.trace("keyword does not cantain an Account.Type");
}
```
on second thought not really simpler or more legible, unless we let the
exception trickle up. ยด) never mind.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]