Closed
Description
It seems that there is newline character after the entity alias name in FROM
part of the query before the JOIN
the distinct is removed from the count.
Incorrect behavior:
@Query("""
SELECT DISTINCT entity1
FROM Entity1 entity1
LEFT JOIN Entity2 entity2 ON entity1.key = entity2.key""")
returns
select count(entity1) FROM Entity1 entity1
LEFT JOIN Entity2 entity2 ON entity1.key = entity2.key
Correct behaviour:
@Query("""
SELECT DISTINCT entity1
FROM Entity1 entity1 LEFT JOIN Entity2 entity2 ON entity1.key = entity2.key""")
returns
select count(DISTINCT entity1) FROM Entity1 entity1 LEFT JOIN Entity2 entity2 ON entity1.key = entity2.key
From testing if the FROM
and JOIN
are in the same line, and WHERE
is new line then this incorrect behavior also occurs.
For now I have solved it with countProjection = "distinct entity1"
.