[OLINGO-1368]Fix for OData in operator for Integer values

This commit is contained in:
ramya vasanth 2020-02-26 11:39:11 +05:30
parent cd7e028b23
commit ac7d8dbd62
1 changed files with 6 additions and 5 deletions

View File

@ -338,7 +338,7 @@ public class ExpressionParser {
if (tokenizer.next(TokenKind.OPEN)) { if (tokenizer.next(TokenKind.OPEN)) {
ParserHelper.bws(tokenizer); ParserHelper.bws(tokenizer);
List<Expression> expressionList = parseInExpr(); List<Expression> expressionList = parseInExpr();
checkInExpressionTypes(expressionList, kinds); checkInExpressionTypes(expressionList, leftExprType);
return new BinaryImpl(left, BinaryOperatorKind.IN, expressionList, return new BinaryImpl(left, BinaryOperatorKind.IN, expressionList,
odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean)); odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean));
} else { } else {
@ -354,19 +354,20 @@ public class ExpressionParser {
/** /**
* @param expressionList * @param expressionList
* @param kinds * @param leftExprType
* @throws UriParserException * @throws UriParserException
* @throws UriParserSemanticException * @throws UriParserSemanticException
*/ */
private void checkInExpressionTypes(List<Expression> expressionList, EdmPrimitiveTypeKind kinds) private void checkInExpressionTypes(List<Expression> expressionList, EdmType leftExprType)
throws UriParserException, UriParserSemanticException { throws UriParserException, UriParserSemanticException {
for (Expression expr : expressionList) { for (Expression expr : expressionList) {
EdmType inExprType = getType(expr); EdmType inExprType = getType(expr);
if (!isType(inExprType, kinds)) {
if (!(((EdmPrimitiveType) leftExprType).isCompatible((EdmPrimitiveType) inExprType))) {
throw new UriParserSemanticException("Incompatible types.", throw new UriParserSemanticException("Incompatible types.",
UriParserSemanticException.MessageKeys.TYPES_NOT_COMPATIBLE, UriParserSemanticException.MessageKeys.TYPES_NOT_COMPATIBLE,
inExprType == null ? "" : inExprType.getFullQualifiedName().getFullQualifiedNameAsString(), inExprType == null ? "" : inExprType.getFullQualifiedName().getFullQualifiedNameAsString(),
kinds.getFullQualifiedName().getFullQualifiedNameAsString()); leftExprType.getFullQualifiedName().getFullQualifiedNameAsString());
} }
} }
} }