-
Notifications
You must be signed in to change notification settings - Fork 933
Fix fetching lazy component with formula #3171
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 4 commits
Commits
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
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
66 changes: 66 additions & 0 deletions
66
src/NHibernate.Test/Async/NHSpecificTest/GH3164/FixtureByCode.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,66 @@ | ||
//------------------------------------------------------------------------------ | ||
// <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.Linq; | ||
using NHibernate.Cfg.MappingSchema; | ||
using NHibernate.Mapping.ByCode; | ||
using NUnit.Framework; | ||
using NHibernate.Linq; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3164 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class ByCodeFixtureAsync : TestCaseMappingByCode | ||
{ | ||
protected override HbmMapping GetMappings() | ||
{ | ||
var mapper = new ModelMapper(); | ||
mapper.AddMapping<ContentItemMapping>(); | ||
mapper.AddMapping<HeadMapping>(); | ||
|
||
return mapper.CompileMappingForAllExplicitlyAddedEntities(); | ||
} | ||
|
||
protected override void OnSetUp() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
var e1 = new ContentItem { Name = "Test" }; | ||
session.Save(e1); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
session.CreateQuery("delete from System.Object").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task FetchComponentAsync() | ||
{ | ||
using (var session = OpenSession()) | ||
{ | ||
var result = await (session.Query<ContentItem>().Fetch(i => i.Head).ToListAsync()); | ||
|
||
Assert.That(result.Count, Is.EqualTo(1)); | ||
} | ||
} | ||
} | ||
} |
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,9 @@ | ||
namespace NHibernate.Test.NHSpecificTest.GH3164 | ||
{ | ||
public class ContentItem | ||
{ | ||
public virtual int Id { get; set; } | ||
public virtual string Name { get; set; } | ||
public virtual IHead Head { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/NHibernate.Test/NHSpecificTest/GH3164/ContentItemMapping.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,16 @@ | ||
using NHibernate.Mapping.ByCode; | ||
using NHibernate.Mapping.ByCode.Conformist; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3164 | ||
{ | ||
public class ContentItemMapping : ClassMapping<ContentItem> | ||
{ | ||
public ContentItemMapping() | ||
{ | ||
Table("ContentItems"); | ||
Id(x => x.Id, m => m.Generator(Generators.Identity)); | ||
Property(x => x.Name); | ||
Component(x => x.Head, x => x.Lazy(true)); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/NHibernate.Test/NHSpecificTest/GH3164/FixtureByCode.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,55 @@ | ||
using System.Linq; | ||
using NHibernate.Cfg.MappingSchema; | ||
using NHibernate.Mapping.ByCode; | ||
using NUnit.Framework; | ||
using NHibernate.Linq; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3164 | ||
{ | ||
[TestFixture] | ||
public class ByCodeFixture : TestCaseMappingByCode | ||
{ | ||
protected override HbmMapping GetMappings() | ||
{ | ||
var mapper = new ModelMapper(); | ||
mapper.AddMapping<ContentItemMapping>(); | ||
mapper.AddMapping<HeadMapping>(); | ||
|
||
return mapper.CompileMappingForAllExplicitlyAddedEntities(); | ||
} | ||
|
||
protected override void OnSetUp() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
var e1 = new ContentItem { Name = "Test" }; | ||
session.Save(e1); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
session.CreateQuery("delete from System.Object").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public void FetchComponent() | ||
{ | ||
using (var session = OpenSession()) | ||
{ | ||
var result = session.Query<ContentItem>().Fetch(i => i.Head).ToList(); | ||
|
||
Assert.That(result.Count, Is.EqualTo(1)); | ||
} | ||
} | ||
} | ||
} |
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,12 @@ | ||
using System; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3164 | ||
{ | ||
[Serializable] | ||
public class Head : IHead | ||
{ | ||
public virtual string Title { get; set; } | ||
|
||
public virtual bool DummyFieldToLoadEmptyComponent { get; } | ||
} | ||
} |
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,24 @@ | ||
using NHibernate.Mapping.ByCode; | ||
using NHibernate.Mapping.ByCode.Conformist; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3164 | ||
{ | ||
public class HeadMapping : ComponentMapping<IHead> | ||
{ | ||
public HeadMapping() | ||
{ | ||
Class<Head>(); | ||
Property(x => x.Title, m => | ||
{ | ||
m.Column("PageTitle"); | ||
m.Lazy(true); | ||
}); | ||
Property(x => x.DummyFieldToLoadEmptyComponent, m => | ||
{ | ||
m.Access(Accessor.ReadOnly); | ||
m.Formula("1"); | ||
}); | ||
Lazy(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace NHibernate.Test.NHSpecificTest.GH3164 | ||
{ | ||
|
||
public interface IHead | ||
{ | ||
string Title { get; set; } | ||
|
||
bool DummyFieldToLoadEmptyComponent { get; } | ||
} | ||
} |
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.