JetDriver: Missing parenthesis in subqueries
Description
Environment
Activity

Esteban Troscé August 6, 2010 at 6:05 AM
great news!!! thanks!

Hadi Eskandari August 6, 2010 at 4:30 AM
Okay as far as for this bug goes, it is reproduced and fixed. Basically second select statements were not processed at all by jet dialect so there may still be some edge cases. Thanks for reporting the bug and following it up.

Esteban Troscé August 4, 2010 at 8:08 AM
One correction about the last query above:
from Catalog c
join c.Category as cat
join c.ProductType as pt
join cat.Product as p
where p.id NOT IN (select pi.id from Catalog ci
join ci.Category as cati
join ci.ProductType as pti
join cati.Product as pi)

Esteban Troscé August 4, 2010 at 8:02 AM
Hadi, I think you didn't get my point.
Your query is OK, but it won't reproduce the issue... To reproduce the issue, your query should be something like:
from Catalog c
join c.Category as cat
join c.ProductType as pt
join cat.Product as p
where c.Category.Name NOT IN ( select cg.Name from Category cg <join something else here, two joins required to make it fail, wou will notice no parenthesis in the inner query> )
You see? The Subquery inside the NOT IN clause shoulg have more than one join (to force the need of parenthesis in the generated SQL) to fail.
maybe, something like the following query helps:
from Catalog c
join c.Category as cat
join c.ProductType as pt
join cat.Product as p
where c NOT IN (select c from Catalog ci
join c.Category as cati
join c.ProductType as pti
join cat.Product as pi)
The query is useless but it will fail. You will notice NO parenthesis in the generated SQL subquery.

Hadi Eskandari August 3, 2010 at 11:15 PM
By the way, if you upgrade to build of the truck, it still uses NHibernate 2.1.0.4000. We plan to provide new build for NHibernate 2.1.2 GA and I'll try to provide official download link from the SourceForge.
Details
Details
Assignee

Reporter

We are using NHibernate.JetDriver version 2.0.0.1001 in our project and realized that when using subqueries, the SQL generated is wrong. It does not contain the required parenthesis for the JOINs.
It happens in both HQL subqueries and Criteria subqueries.
A quick way to reproduce it is to generate an HQL with a NOT IN clause. In the inner subquery, add several joins and try to run it. It won't have parenthesis and will fail.