HHH-16449 accept underscores in HQL integer and long literals
This commit is contained in:
parent
34f05d183a
commit
bd57af6d97
|
@ -58,9 +58,9 @@ FLOATING_POINT_NUMBER
|
|||
| DIGIT+
|
||||
;
|
||||
|
||||
INTEGER_LITERAL : INTEGER_NUMBER;
|
||||
INTEGER_LITERAL : INTEGER_NUMBER ('_' INTEGER_NUMBER)*;
|
||||
|
||||
LONG_LITERAL : INTEGER_NUMBER LONG_SUFFIX;
|
||||
LONG_LITERAL : INTEGER_NUMBER ('_' INTEGER_NUMBER)* LONG_SUFFIX;
|
||||
|
||||
FLOAT_LITERAL : FLOATING_POINT_NUMBER FLOAT_SUFFIX?;
|
||||
|
||||
|
|
|
@ -3622,7 +3622,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
|||
|
||||
private SqmLiteral<? extends Number> integerOrLongLiteral(String text) {
|
||||
try {
|
||||
final Integer value = Integer.valueOf( text );
|
||||
final Integer value = Integer.valueOf( text.replace("_", "") );
|
||||
return new SqmLiteral<>(
|
||||
value,
|
||||
resolveExpressibleTypeBasic( Integer.class ),
|
||||
|
@ -3651,7 +3651,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
|||
|
||||
private SqmLiteral<Integer> integerLiteral(String text) {
|
||||
try {
|
||||
final Integer value = Integer.valueOf( text );
|
||||
final Integer value = Integer.valueOf( text.replace("_", "") );
|
||||
return new SqmLiteral<>(
|
||||
value,
|
||||
resolveExpressibleTypeBasic( Integer.class ),
|
||||
|
@ -3670,7 +3670,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
|||
final String originalText = text;
|
||||
try {
|
||||
if ( text.endsWith( "l" ) || text.endsWith( "L" ) ) {
|
||||
text = text.substring( 0, text.length() - 1 );
|
||||
text = text.substring( 0, text.length() - 1 ).replace("_", "");
|
||||
}
|
||||
final Long value = Long.valueOf( text );
|
||||
return new SqmLiteral<>(
|
||||
|
|
|
@ -302,6 +302,8 @@ public class LiteralTests {
|
|||
scope.inTransaction(
|
||||
session -> {
|
||||
assertThat( session.createQuery( "select 1" ).getSingleResult(), is( 1 ) );
|
||||
assertThat( session.createQuery( "select 1_000_000" ).getSingleResult(), is( 1_000_000 ) );
|
||||
assertThat( session.createQuery( "select 1_000_000L" ).getSingleResult(), is( 1_000_000L ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue