Add additional tests to verify proper detection of alias values.

In the past, a token with "from" buried in it would trip up QueryUtils. These tests further demonstrate that this is no longer an issue with the HQL parser.

Related: #2508.
This commit is contained in:
Greg L. Turnquist
2023-03-22 15:58:00 -05:00
parent efc9aed64e
commit 2f6955ec0a

View File

@@ -808,6 +808,17 @@ class HqlQueryTransformerTests {
"select count(b) FROM BookError b WHERE portal = :portal");
}
@Test // GH-2508
void detectAliasWithCastCorrectly() {
assertThat(alias("from User u where (cast(:effective as date) is null) OR :effective >= u.createdAt"))
.isEqualTo("u");
assertThat(alias("from User u where (cast(:effectiveDate as date) is null) OR :effectiveDate >= u.createdAt"))
.isEqualTo("u");
assertThat(alias("from User u where (cast(:effectiveFrom as date) is null) OR :effectiveFrom >= u.createdAt"))
.isEqualTo("u");
}
private void assertCountQuery(String originalQuery, String countQuery) {
assertThat(createCountQueryFor(originalQuery)).isEqualTo(countQuery);
}