Skip to content

Commit

Permalink
extra tests for camel casing and where clauses, addressed issue w/ Co…
Browse files Browse the repository at this point in the history
…llectionIsEmpty
  • Loading branch information
jeremydmiller committed Oct 8, 2024
1 parent a63b3e1 commit c82ea9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/LinqTests/Acceptance/Support/DefaultQueryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public class DefaultQueryFixture: TargetSchemaFixture
{
public DefaultQueryFixture()
{
Store = provisionStore("linq_querying");
Store = ProvisionStore("linq_querying");


DuplicatedFieldStore = provisionStore("duplicate_fields", o =>
DuplicatedFieldStore = ProvisionStore("duplicate_fields", o =>
{
o.Schema.For<Target>()
.Duplicate(x => x.Number)
Expand All @@ -25,7 +25,7 @@ public DefaultQueryFixture()
.Duplicate(x => x.NumberArray);
});

SystemTextJsonStore = provisionStore("stj", o =>
SystemTextJsonStore = ProvisionStore("stj", o =>
{
o.Serializer<SystemTextJsonSerializer>();
});
Expand Down
4 changes: 2 additions & 2 deletions src/LinqTests/Acceptance/Support/TargetSchemaFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Dispose()
}
}

protected DocumentStore provisionStore(string schema, Action<StoreOptions> configure = null)
internal DocumentStore ProvisionStore(string schema, Action<StoreOptions> configure = null)
{
var store = DocumentStore.For(x =>
{
Expand All @@ -39,4 +39,4 @@ protected DocumentStore provisionStore(string schema, Action<StoreOptions> confi

return store;
}
}
}
10 changes: 10 additions & 0 deletions src/LinqTests/Acceptance/child_collection_queries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public Task run_query(string description)
return assertTestCase(description, Fixture.Store);
}

[Theory]
[MemberData(nameof(GetDescriptions))]
public Task run_query_with_camel_casing(string description)
{
var store = Fixture.ProvisionStore("linq_with_camel_casing",
opts => opts.UseSystemTextJsonForSerialization(casing: Casing.CamelCase));

return assertTestCase(description, store);
}


[Theory]
[MemberData(nameof(GetDescriptions))]
Expand Down
4 changes: 3 additions & 1 deletion src/Marten/Linq/SqlGeneration/Filters/CollectionIsEmpty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ internal class CollectionIsEmpty: IReversibleWhereFragment
public CollectionIsEmpty(ICollectionMember member)
{
_member = member;
_text = $"d.data @? '$ ? (@.{member.MemberName} == null || @.{member.MemberName}.size() == 0)'";
// deeply ashamed by the replace here, but it does work.
var jsonPath = member.WriteJsonPath().Replace("[*]", "");
_text = $"d.data @? '$ ? (@.{jsonPath} == null || @.{jsonPath}.size() == 0)'";
}

public ISqlFragment Reverse()
Expand Down

0 comments on commit c82ea9e

Please sign in to comment.