-
-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded JasperFx.CodeGeneration and hardened the compiled query code…
… generation for various types of primitive arrays as parameter values. Closes GH-3610
- Loading branch information
1 parent
5c4b552
commit 53e0257
Showing
3 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
src/LinqTests/Bugs/Bug_3610_enum_array_as_string_in_compiled_query.cs
This file contains 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,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Threading.Tasks; | ||
using Marten; | ||
using Marten.Linq; | ||
using Marten.Testing.Harness; | ||
using Shouldly; | ||
using Weasel.Core; | ||
|
||
namespace LinqTests.Bugs; | ||
|
||
public class Bug_3610_enum_array_as_string_in_compiled_query : BugIntegrationContext | ||
{ | ||
[Fact] | ||
public async Task use_the_query() | ||
{ | ||
StoreOptions(opts => | ||
{ | ||
opts.UseNewtonsoftForSerialization(enumStorage: EnumStorage.AsString, | ||
nonPublicMembersStorage: NonPublicMembersStorage.NonPublicSetters); | ||
}); | ||
|
||
var elayne = new Foo { Name = "Elayne", Status = StatusEnum.Active }; | ||
theSession.Store(elayne); | ||
await theSession.SaveChangesAsync(); | ||
|
||
var results = await theSession.QueryAsync(new ActiveFooQuery("Elayne")); | ||
|
||
results.Any().ShouldBeTrue(); | ||
} | ||
} | ||
|
||
public class ActiveFooQuery : ICompiledListQuery<Foo>, IQueryPlanning | ||
{ | ||
public string Name { get; set; } | ||
public ActiveFooQuery() | ||
{ | ||
|
||
} | ||
|
||
public ActiveFooQuery(string name) | ||
{ | ||
Name = name; | ||
} | ||
|
||
public Expression<Func<IMartenQueryable<Foo>, IEnumerable<Foo>>> QueryIs() => | ||
q => q.Where(x => x.Status.In(StatusEnum.Active) && x.Name == Name); | ||
|
||
public void SetUniqueValuesForQueryPlanning() | ||
{ | ||
Name = "ActiveFooQuery"; | ||
} | ||
} | ||
|
||
public class Foo | ||
{ | ||
public Guid Id { get; set; } | ||
public StatusEnum Status { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
public enum StatusEnum | ||
{ | ||
Active, | ||
Inactive | ||
} |
This file contains 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
This file contains 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