-
Notifications
You must be signed in to change notification settings - Fork 936
Closed
Milestone
Description
There seems to be a regression after upgrading from 5.1.6 to 5.3.5.
Calling code:
session.Query<MenuRow>()
.Select(x => x.LimitForCanteens.Any())
.ToList();
Table LimitForCanteens has a composite key.
NHibernate 5.1.6 output:
select
case
when exists (select
limitforca1_.jidlo_pc,
limitforca1_.id_vydejna
from
dba.MenuRowLimitForCanteen limitforca1_
where
menurow0_.pc=limitforca1_.jidlo_pc) then 1
else 0
end as col_0_0_
from
dba.MenuRow menurow0_
NHibernate 5.3.5 output:
select
case
when exists (select
(limitforca1_.jidlo_pc,
limitforca1_.id_vydejna)
from
dba.MenuRowLimitForCanteen limitforca1_
where
menurow0_.pc=limitforca1_.jidlo_pc) then 1
else 0
end as col_0_0_
from
dba.MenuRow menurow0_
Notice the extra parentheses around the inner select columns. This does not run in SQL Server 2019.
I searched around in Issues/PRs, only thing I could find was https://github.com/nhibernate/nhibernate-core/pull/2159/files#diff-2d749e6ec720561e02b40a017ad53c5191a3299120421e88f7b38d63aebea450.
The deleted comment there mentions this exact thing.
Mappings:
<class name="MenuRow" table="MenuRow" schema="dba" dynamic-insert="true" dynamic-update="true" p1:Guid="0b073ff6-a654-49c6-af7d-a840e1306502">
<composite-id>
<key-property name="Date" type="DateTime" p1:ValidateRequired="true" p1:Guid="e3ebe478-2b1c-4d08-a2c4-f8fe5db67d69">
<column name="datum" not-null="true" sql-type="datetime" p1:unicode="false" />
</key-property>
<key-property name="MealAlt" type="Int16" p1:ValidateRequired="true" p1:Guid="6395bf32-7b91-4dde-94c4-9031e436ada2">
<column name="jidlo_alt" not-null="true" precision="5" scale="0" sql-type="smallint" p1:unicode="false" />
</key-property>
</composite-id>
<property name="MenuRowId" type="Int32" generated="insert" p1:ValidateRequired="true" p1:Guid="8cf2c1e3-24b9-4984-8b30-aa4950e0a646">
<column name="pc" not-null="true" precision="10" scale="0" sql-type="int" unique="true" p1:unicode="false" />
</property>
<set name="LimitForCanteens" lazy="extra" inverse="true" cascade="all" generic="true" p1:AssociationGuid="32bdeec3-6aad-4ba9-a80e-d64f06b2f8a9" p1:Guid="eb2fd18c-5c21-430e-812d-cfddd4674372">
<key property-ref="MenuRowId">
<column name="jidlo_pc" />
</key>
<one-to-many class="MenuRowLimitForCanteen" />
</set>
</class>
<class name="MenuRowLimitForCanteen" table="MenuRowLimitForCanteen" schema="dba" p1:Guid="f017e587-10f3-4998-900c-ff907b0ccf84">
<composite-id>
<key-property name="MenuRowId" type="Int32" p1:ValidateRequired="true" p1:Guid="92d4c32e-986e-4bfd-990d-714d13926188">
<column name="jidlo_pc" not-null="true" precision="10" scale="0" sql-type="int" p1:unicode="false" />
</key-property>
<key-property name="CanteenId" type="Int16" p1:ValidateRequired="true" p1:Guid="129374e0-40e6-48d7-87a8-0193195a5996">
<column name="id_vydejna" not-null="true" precision="5" scale="0" sql-type="smallint" p1:unicode="false" />
</key-property>
</composite-id>
<property name="LimitForCanteen" type="Int16" p1:ValidateRequired="true" p1:Guid="d0ce7883-55f2-4666-9284-b609b76e59d9">
<column name="limit" default="0" not-null="true" precision="5" scale="0" sql-type="smallint" p1:unicode="false" />
</property>
<many-to-one name="MenuRow" class="MenuRow" update="false" insert="false" property-ref="MenuRowId" p1:AssociationGuid="32bdeec3-6aad-4ba9-a80e-d64f06b2f8a9" p1:Guid="47cb86b3-6e2c-451c-89e4-c380f56b96e5">
<column name="jidlo_pc" not-null="true" precision="10" scale="0" sql-type="int" p1:unicode="false" />
</many-to-one>
</class>