GH-4705: Fix FilterExpressionTextParser to handle Long values in numeric literals
fixed: https://github.com/spring-projects/spring-ai/issues/4705 -- FilterExpressionTextParser treats all number literals as Integer, failing on Long values
Hi @leehaut, thanks for your contribution.
I believe your PR has become irrelevant since we merged https://github.com/spring-projects/spring-ai/pull/3516.
Can you please confirm this is the case.
Hi @ericbottard, I tried testing with long types or hexadecimal (0x) values, and found that ANTLR always converts them to int. ANTLR cannot distinguish between int and long. .e.g.
@MethodSource("constantConstantProvider")
@ParameterizedTest(name = "{index} => [{0}, expected={1}]")
void testConstants(String expr, Object expectedValue) {
Expression result = this.parser.parse(expr);
assertThat(result).isEqualTo(new Expression(EQ, new Key("id"), new Value(expectedValue)));
}
static Stream<Arguments> constantConstantProvider() {
return Stream.of(Arguments.of("id==" + Integer.MAX_VALUE, Integer.MAX_VALUE),
Arguments.of("id==" + Integer.MIN_VALUE, Integer.MIN_VALUE),
Arguments.of("id==" + Long.MAX_VALUE, Long.MAX_VALUE),
Arguments.of("id==" + Long.MIN_VALUE, Long.MIN_VALUE), Arguments.of("id==" + 0x100, 0x100),
Arguments.of("id==" + 1000000000000L, 1000000000000L), Arguments.of("id==" + Math.PI, Math.PI));
}
Hi,
the linked PR introduces support for longs by using the 1234L notation.