The testWithClause from WithClauseTest class fails on PostgreSQL

Description

While this test runs just fine on H2, on PostgreSQL, it fails with the following error message:

1 2 Caused by: org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "human2_2_" Position: 1701

The query in question looks like this:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 select human0_.mammal as id1_3_0_, human2_.mammal as id1_3_1_, human0_2_.description as descript2_3_0_, human0_2_.body_weight as body_wei3_3_0_, human0_2_.mother_id as mother_i4_3_0_, human0_2_.father_id as father_i5_3_0_, human0_2_.zoo_id as zoo_id6_3_0_, human0_2_.serialNumber as serialNu7_3_0_, human0_1_.pregnant as pregnant2_14_0_, human0_1_.birthdate as birthdat3_14_0_, human0_.name_first as name_fir2_7_0_, human0_.name_initial as name_ini3_7_0_, human0_.name_last as name_las4_7_0_, human0_.nickName as nickName5_7_0_, human0_.height_centimeters / 2.54E0 as height_c6_7_0_, human0_.intValue as intValue7_7_0_, human0_.floatValue as floatVal8_7_0_, human0_.bigDecimalValue as bigDecim9_7_0_, human0_.bigIntegerValue as bigInte10_7_0_, human2_2_.description as descript2_3_1_, human2_2_.body_weight as body_wei3_3_1_, human2_2_.mother_id as mother_i4_3_1_, human2_2_.father_id as father_i5_3_1_, human2_2_.zoo_id as zoo_id6_3_1_, human2_2_.serialNumber as serialNu7_3_1_, human2_1_.pregnant as pregnant2_14_1_, human2_1_.birthdate as birthdat3_14_1_, human2_.name_first as name_fir2_7_1_, human2_.name_initial as name_ini3_7_1_, human2_.name_last as name_las4_7_1_, human2_.nickName as nickName5_7_1_, human2_.height_centimeters / 2.54E0 as height_c6_7_1_, human2_.intValue as intValue7_7_1_, human2_.floatValue as floatVal8_7_1_, human2_.bigDecimalValue as bigDecim9_7_1_, human2_.bigIntegerValue as bigInte10_7_1_ from Human human0_ inner join Mammal human0_1_ on human0_.mammal=human0_1_.animal inner join Animal human0_2_ on human0_.mammal=human0_2_.id inner join Human_friends friends1_ on human0_.mammal=friends1_.human1 inner join Human human2_ on friends1_.human2=human2_.mammal and ( human2_2_.body_weight<? ) inner join Mammal human2_1_ on human2_.mammal=human2_1_.animal inner join Animal human2_2_ on human2_.mammal=human2_2_.id

It could be because the human2_2_ alias is referenced in a JOIN ON clause before it's being declared in an INNER JOIN as an alias.

Environment

None

Status

Assignee

Christian Beikov

Reporter

Vlad Mihalcea

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

5.2.7

Priority

Major