-
Notifications
You must be signed in to change notification settings - Fork 931
Support association joins from main query to be used in subqueries #3369
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
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e33120c
Test case
csharper2010 57e2623
More test cases and clean up
bahusoid 43fefb9
Fix
bahusoid 2cedbd5
Skip tests for MySql
bahusoid d638d3d
Return old behavior for implicit joins in subquery
bahusoid 05779ac
Clean up testcase for GH1228
bahusoid 46b148c
Fix GH1228 test
bahusoid 41fc760
Clean up
bahusoid 03d0972
Generate async files
github-actions[bot] 73bc158
Apply suggestions from code review
bahusoid 6fa5895
Commit forgoten suggestion
fredericDelaporte 2cf2dc3
Generate async version of GH1228
fredericDelaporte 2a1f31d
Generate async files
github-actions[bot] 597524f
Fix test name
bahusoid 91f2e61
Generate async files
github-actions[bot] 0c7899c
Merge branch 'master' into gh3334new
bahusoid 415b793
Merge branch 'master' into gh3334new
bahusoid d1277f0
Merge branch 'master' into gh3334new
bahusoid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
204 changes: 204 additions & 0 deletions
204
src/NHibernate.Test/Async/NHSpecificTest/GH3334/Fixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3334 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class FixtureAsync : BugTestCase | ||
{ | ||
[OneTimeSetUp] | ||
public void OneTimeSetUp() | ||
{ | ||
using var session = OpenSession(); | ||
using var t = session.BeginTransaction(); | ||
var parent = new Entity | ||
{ | ||
Name = "Parent1", | ||
Children = { new ChildEntity { Name = "Child", Child = new GrandChildEntity { Name = "GrandChild" } } } | ||
}; | ||
session.Save(parent); | ||
parent = new Entity | ||
{ | ||
Name = "Parent2", | ||
Children = { new ChildEntity { Name = "Child", Child = new GrandChildEntity { Name = "XGrandChild" } } } | ||
}; | ||
var other = new OtherEntity { Name = "ABC", Entities = {parent}}; | ||
parent.OtherEntity = other; | ||
session.Save(parent); | ||
session.Save(other); | ||
t.Commit(); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void OneTimeTearDown() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
|
||
session.CreateQuery("delete from ChildEntity").ExecuteUpdate(); | ||
session.CreateQuery("delete from GrandChildEntity").ExecuteUpdate(); | ||
session.CreateQuery("delete from Entity").ExecuteUpdate(); | ||
session.CreateQuery("delete from OtherEntity").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
|
||
protected override bool AppliesTo(Dialect.Dialect dialect) | ||
{ | ||
return TestDialect.SupportsCorrelatedColumnsInSubselectJoin; | ||
} | ||
|
||
public class TestCaseItem | ||
{ | ||
public string Name { get; } | ||
public string Hql { get; } | ||
public int LineNumber { get; } | ||
|
||
public TestCaseItem(string name, string hql, [CallerLineNumber] int lineNumber = 0) | ||
{ | ||
Name = name; | ||
Hql = hql; | ||
LineNumber = lineNumber; | ||
} | ||
|
||
public override string ToString() => $"{LineNumber:0000}: {Name}"; | ||
} | ||
|
||
public static IEnumerable<TestCaseItem> GetNoExceptionOnExecuteQueryTestCases() | ||
{ | ||
/* does not work because of inner join or theta join created for many-to-one | ||
@" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ELEMENTS(ROOT.Children) AS child | ||
WHERE | ||
child.Child.Name like 'G%' | ||
OR ROOT.OtherEntity.Name like 'A%' | ||
)");*/ | ||
|
||
yield return new("Basic Elements case 1 FoundViaGrandChildG", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ELEMENTS(ROOT.Children) AS child | ||
LEFT JOIN child.Child AS grandChild | ||
WHERE | ||
grandChild.Name like 'G%' | ||
)"); | ||
yield return new("Basic Elements case 2 FoundViaOtherEntityA", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ELEMENTS(ROOT.OtherEntity) AS otherEntity | ||
WHERE | ||
otherEntity.Name like 'A%' | ||
)"); | ||
yield return new("HQL Elements FoundViaGrandChildG", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ELEMENTS(ROOT.Children) AS child | ||
LEFT JOIN child.Child AS grandChild | ||
LEFT JOIN ROOT.OtherEntity AS otherEntity | ||
WHERE | ||
grandChild.Name like 'G%' | ||
OR otherEntity.Name like 'G%' | ||
)"); | ||
yield return new("HQL Elements FoundViaOtherEntityA", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ELEMENTS(ROOT.Children) AS child | ||
LEFT JOIN child.Child AS grandChild | ||
LEFT JOIN ROOT.OtherEntity AS otherEntity | ||
WHERE | ||
grandChild.Name like 'A%' | ||
OR otherEntity.Name like 'A%' | ||
)"); | ||
yield return new("HQL Entity FoundViaGrandChildG", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ChildEntity AS child | ||
LEFT JOIN child.Child AS grandChild | ||
LEFT JOIN ROOT.OtherEntity AS otherEntity | ||
WHERE | ||
child.Parent = ROOT | ||
AND ( | ||
grandChild.Name like 'G%' | ||
OR otherEntity.Name like 'G%' | ||
) | ||
)"); | ||
yield return new("HQL Entity FoundViaOtherEntityA", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ChildEntity AS child | ||
LEFT JOIN child.Child AS grandChild | ||
LEFT JOIN ROOT.OtherEntity AS otherEntity | ||
WHERE | ||
child.Parent = ROOT | ||
AND ( | ||
grandChild.Name like 'A%' | ||
OR otherEntity.Name like 'A%' | ||
) | ||
)"); | ||
yield return new("FROM ROOT.Children FoundViaGrandChildG", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ROOT.Children AS child | ||
LEFT JOIN child.Child AS grandChild | ||
WHERE | ||
grandChild.Name like 'G%' | ||
)"); | ||
yield return new("FROM ROOT.OtherEntity FoundViaOtherEntityA", @" | ||
SELECT ROOT | ||
FROM Entity AS ROOT | ||
WHERE | ||
EXISTS | ||
(FROM ROOT.OtherEntity AS otherEntity | ||
LEFT JOIN ChildEntity AS child ON child.Parent = ROOT | ||
LEFT JOIN child.Child AS grandChild | ||
WHERE | ||
grandChild.Name like 'A%' | ||
OR otherEntity.Name like 'A%' | ||
)"); | ||
} | ||
|
||
[Test, TestCaseSource(nameof(GetNoExceptionOnExecuteQueryTestCases))] | ||
public async Task NoExceptionOnExecuteQueryAsync(TestCaseItem testCase) | ||
{ | ||
using var session = OpenSession(); | ||
var q = session.CreateQuery(testCase.Hql); | ||
Assert.That(await (q.ListAsync()), Has.Count.EqualTo(1)); | ||
} | ||
|
||
protected override bool CheckDatabaseWasCleaned() | ||
{ | ||
// same set of objects for each test | ||
return true; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.