-
Notifications
You must be signed in to change notification settings - Fork 932
Fix AND/OR negation logic in hql #3328
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 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9027962
Fixes #3327
csharper2010 94f3c20
Generate async files
github-actions[bot] b4dd081
Try fix tests
bahusoid ce40a2e
Fix without new node creation
bahusoid 284ad00
Merge branch 'master' into GH3327
bahusoid 29262ce
test cleanup
bahusoid f4bb50c
Generate async files
github-actions[bot] fcdd937
Merge branch 'master' into GH3327
bahusoid 7253ed8
Merge branch 'master' into GH3327
hazzik 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
74 changes: 74 additions & 0 deletions
74
src/NHibernate.Test/Async/NHSpecificTest/GH3327/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,74 @@ | ||
| //------------------------------------------------------------------------------ | ||
| // <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; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace NHibernate.Test.NHSpecificTest.GH3327 | ||
| { | ||
| using System.Threading.Tasks; | ||
| [TestFixture] | ||
| public class FixtureAsync : BugTestCase | ||
| { | ||
| protected override void OnSetUp() | ||
| { | ||
| Sfi.Statistics.IsStatisticsEnabled = true; | ||
| } | ||
|
|
||
| protected override void OnTearDown() | ||
| { | ||
| Sfi.Statistics.IsStatisticsEnabled = false; | ||
| using (var session = OpenSession()) | ||
| using (var transaction = session.BeginTransaction()) | ||
| { | ||
| session.CreateQuery("delete from ChildEntity").ExecuteUpdate(); | ||
| session.CreateQuery("delete from Entity").ExecuteUpdate(); | ||
|
|
||
| transaction.Commit(); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task NotIsCorrectlyHandledAsync() | ||
| { | ||
| using (var session = OpenSession()) | ||
| using (var t = session.BeginTransaction()) | ||
| { | ||
| var parent = new Entity { Name = "Parent" }; | ||
| var child = new ChildEntity { Name = "Child", Parent = parent }; | ||
| await (session.SaveAsync(parent)); | ||
| await (session.SaveAsync(child)); | ||
| await (t.CommitAsync()); | ||
| } | ||
|
|
||
| using (var session = OpenSession()) | ||
| using (var _ = session.BeginTransaction()) | ||
| { | ||
| var q = session.CreateQuery( | ||
| @"SELECT COUNT(ROOT.Id) | ||
| FROM Entity AS ROOT | ||
| WHERE ( | ||
| EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT) | ||
| AND ROOT.Name = 'Parent' | ||
| )"); | ||
| Assert.That((await (q.ListAsync()))[0], Is.EqualTo(1)); | ||
|
|
||
| q = session.CreateQuery( | ||
| @"SELECT COUNT(ROOT.Id) | ||
| FROM Entity AS ROOT | ||
| WHERE NOT ( | ||
| EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT) | ||
| AND ROOT.Name = 'Parent' | ||
| )"); | ||
| Assert.That((await (q.ListAsync()))[0], Is.EqualTo(0)); | ||
| } | ||
| } | ||
| } | ||
| } |
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,17 @@ | ||
| using System; | ||
|
|
||
| namespace NHibernate.Test.NHSpecificTest.GH3327 | ||
| { | ||
| public class Entity | ||
| { | ||
| public virtual int Id { get; set; } | ||
| public virtual string Name { get; set; } | ||
| } | ||
|
|
||
| public class ChildEntity | ||
| { | ||
| public virtual int Id { get; set; } | ||
| public virtual Entity Parent { get; set; } | ||
| public virtual string Name { get; set; } | ||
| } | ||
| } |
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,63 @@ | ||
| using System; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace NHibernate.Test.NHSpecificTest.GH3327 | ||
| { | ||
| [TestFixture] | ||
| public class Fixture : BugTestCase | ||
| { | ||
| protected override void OnSetUp() | ||
| { | ||
| Sfi.Statistics.IsStatisticsEnabled = true; | ||
| } | ||
|
|
||
| protected override void OnTearDown() | ||
| { | ||
| Sfi.Statistics.IsStatisticsEnabled = false; | ||
| using (var session = OpenSession()) | ||
| using (var transaction = session.BeginTransaction()) | ||
| { | ||
| session.CreateQuery("delete from ChildEntity").ExecuteUpdate(); | ||
| session.CreateQuery("delete from Entity").ExecuteUpdate(); | ||
|
|
||
| transaction.Commit(); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public void NotIsCorrectlyHandled() | ||
| { | ||
| using (var session = OpenSession()) | ||
| using (var t = session.BeginTransaction()) | ||
| { | ||
| var parent = new Entity { Name = "Parent" }; | ||
| var child = new ChildEntity { Name = "Child", Parent = parent }; | ||
| session.Save(parent); | ||
| session.Save(child); | ||
| t.Commit(); | ||
| } | ||
|
|
||
| using (var session = OpenSession()) | ||
| using (var _ = session.BeginTransaction()) | ||
| { | ||
| var q = session.CreateQuery( | ||
| @"SELECT COUNT(ROOT.Id) | ||
| FROM Entity AS ROOT | ||
| WHERE ( | ||
| EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT) | ||
| AND ROOT.Name = 'Parent' | ||
| )"); | ||
| Assert.That(q.List()[0], Is.EqualTo(1)); | ||
|
|
||
| q = session.CreateQuery( | ||
| @"SELECT COUNT(ROOT.Id) | ||
| FROM Entity AS ROOT | ||
| WHERE NOT ( | ||
| EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT) | ||
| AND ROOT.Name = 'Parent' | ||
| )"); | ||
| Assert.That(q.List()[0], Is.EqualTo(0)); | ||
| } | ||
| } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/NHibernate.Test/NHSpecificTest/GH3327/Mappings.hbm.xml
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,16 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" | ||
| namespace="NHibernate.Test.NHSpecificTest.GH3327"> | ||
|
|
||
| <class name="Entity"> | ||
| <id name="Id" generator="identity" /> | ||
| <property name="Name"/> | ||
| </class> | ||
|
|
||
| <class name="ChildEntity"> | ||
| <id name="Id" generator="identity" /> | ||
| <many-to-one name="Parent" class="Entity" not-null="true" /> | ||
| <property name="Name"/> | ||
| </class> | ||
|
|
||
| </hibernate-mapping> |
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
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.