Skip to content

NH-3889 - Fixed weird extra joins in subqueries #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2017

Conversation

PleasantD
Copy link
Contributor

map.Column("SettingId");
});

//rc.Bag(x => x.Parts, map =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No commented code, please

@hazzik
Copy link
Member

hazzik commented Jul 22, 2016

Please fix new tests in the Firbird, and otherwise good to go.

@PleasantD
Copy link
Contributor Author

Fixed up.
Does the Firebird provider not escape column or table names? I think this is the second time I've had conflicts with reserved keywords in Firebird.

@hazzik
Copy link
Member

hazzik commented Jul 25, 2016

@PleasantD not sure about Firebird

@hazzik
Copy link
Member

hazzik commented Jul 30, 2016

LGTM

@PleasantD
Copy link
Contributor Author

Rebased on master

@PleasantD
Copy link
Contributor Author

Can this be included in 4.1.0?

@oskarb
Copy link
Member

oskarb commented Nov 21, 2016

Thanks for rebase. I think I've noticed this phenomenon too. Can you check if Hibernate have made a similar change or otherwise differ from what we have in this code?

@PleasantD
Copy link
Contributor Author

Hibernate seems to grammar similar to ours before my change.
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/antlr/hql-sql.g

selectExprList is identical to NH before the change
query! is similar to the NH unionedQuery! before the change, although the NH grammar seems to cover more syntax possibilities.

So, no, it doesn't look like they have made any similar fix.

@oskarb
Copy link
Member

oskarb commented Nov 26, 2016

The test cases fail on SQL Server CE. We need some resolution for that before merging.

@PleasantD
Copy link
Contributor Author

I rolled back the grammar change and ran the tests.
The same 4 tests were failing before the the change, with the same error:

[SQL: select job0_.Id as col_0_0_, (select cast(sum(timerecord1_.Hours) as NUMERIC(19,5)) from TimeRecord timerecord1_ left outer join Project project2_ on timerecord1_.ProjectId=project2_.Id inner join TimeSetting timesettin3_ on timerecord1_.SettingId=timesettin3_.Id, TimeInclude timeinclud4_ where timesettin3_.IncludeId=timeinclud4_.Id and coalesce(timerecord1_.ActualJobId, project2_.JobId)=job0_.Id and timesettin3_.IncludeId=@p0) as col_1_0_, job0_.Id as Id1_0_, job0_.Name as Name2_0_ from Job job0_]
  ----> System.Data.SqlServerCe.SqlCeException : There was an error parsing the query. [ Token line number = 1,Token line offset = 31,Token in error = select ]

The issue isn't with the grammar change, but that SQL Server CE does not support subqueries that return a scalar result. The four failing tests all generate a subquery with a SUM result in the SELECT clause which just won't parse for SQL Server CE.

With that in mind, what is the policy for ignoring tests that fail on a single dialect?

@hazzik hazzik modified the milestone: 5.0.0 Feb 12, 2017
@hazzik
Copy link
Member

hazzik commented Feb 12, 2017

Hi @PleasantD, can you please enable Allow edits from maintainers feature?

@PleasantD
Copy link
Contributor Author

Done

@hazzik hazzik merged commit 90f5234 into nhibernate:master Feb 18, 2017
@hazzik
Copy link
Member

hazzik commented Feb 18, 2017

Thanks, @PleasantD. Merged

@PleasantD PleasantD deleted the NH-3889 branch March 6, 2017 21:22
@hazzik hazzik added the r: Fixed label Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants