Skip to content

Commit

Permalink
Adjusting the LINQ parser to be able to handle the way that oData bui…
Browse files Browse the repository at this point in the history
…lds up Where() clauses. Closes GH-3198
  • Loading branch information
jeremydmiller committed May 20, 2024
1 parent 47b8f18 commit c59545d
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 82 deletions.
30 changes: 0 additions & 30 deletions src/.dockerignore

This file was deleted.

7 changes: 6 additions & 1 deletion src/AspNetODataWithMarten/AspNetODataWithMarten.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Marten\Marten.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Marten.Testing\Harness\ConnectionSource.cs">
<Link>ConnectionSource.cs</Link>
</Compile>
</ItemGroup>

</Project>
24 changes: 0 additions & 24 deletions src/AspNetODataWithMarten/Dockerfile

This file was deleted.

12 changes: 8 additions & 4 deletions src/AspNetODataWithMarten/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
using Microsoft.AspNetCore.OData;
using Microsoft.OData.ModelBuilder;
using System.ComponentModel.DataAnnotations;
using Marten.Testing.Harness;

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseKestrel(serverOptions =>
{
serverOptions.ListenAnyIP(4000);
});

builder.Services.AddMarten((options) =>
{
options.Connection(Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_STRING"));
options.RegisterDocumentType<WeatherForecast>();
options.DatabaseSchemaName = "public";
options.Connection(ConnectionSource.ConnectionString);
});

builder.Services.AddControllers().AddOData(options =>
Expand All @@ -21,7 +25,7 @@

options.EnableQueryFeatures().AddRouteComponents("odata", entityBuilder.GetEdmModel());
});

var app = builder.Build();

app.MapControllers();
Expand Down
14 changes: 0 additions & 14 deletions src/AspNetODataWithMarten/Properties/launchSettings.json

This file was deleted.

2 changes: 0 additions & 2 deletions src/IssueService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "IssueService v1"));
}

app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();
Expand Down
2 changes: 2 additions & 0 deletions src/LinqTests/Acceptance/where_clauses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public where_clauses(DefaultQueryFixture fixture, ITestOutputHelper output) : ba

static where_clauses()
{
@where(x => (x.Number == 1) == true);

@where(x => x.Number == 1);
@where(x => x.Number > 3);
@where(x => x.Number < 3);
Expand Down
7 changes: 0 additions & 7 deletions src/Marten.sln
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OData", "OData", "{93FC8079
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetODataWithMarten", "AspNetODataWithMarten\AspNetODataWithMarten.csproj", "{93298A4C-2B88-4EF3-9FC8-6B2AEF52F628}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{0F9F373E-A47A-4028-AAEB-04E2FE4E7F24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -254,10 +252,6 @@ Global
{93298A4C-2B88-4EF3-9FC8-6B2AEF52F628}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93298A4C-2B88-4EF3-9FC8-6B2AEF52F628}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93298A4C-2B88-4EF3-9FC8-6B2AEF52F628}.Release|Any CPU.Build.0 = Release|Any CPU
{0F9F373E-A47A-4028-AAEB-04E2FE4E7F24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F9F373E-A47A-4028-AAEB-04E2FE4E7F24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F9F373E-A47A-4028-AAEB-04E2FE4E7F24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F9F373E-A47A-4028-AAEB-04E2FE4E7F24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -297,7 +291,6 @@ Global
{00DBDB5E-FE7B-4886-A989-181331DDD148} = {79961196-DB50-4AD3-B749-D231799BCF2E}
{93FC8079-48C4-4D3B-8C17-3944A903674F} = {79961196-DB50-4AD3-B749-D231799BCF2E}
{93298A4C-2B88-4EF3-9FC8-6B2AEF52F628} = {93FC8079-48C4-4D3B-8C17-3944A903674F}
{0F9F373E-A47A-4028-AAEB-04E2FE4E7F24} = {93FC8079-48C4-4D3B-8C17-3944A903674F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {52B7158F-0A24-47D9-9CF7-3FA94170041A}
Expand Down
10 changes: 10 additions & 0 deletions src/Marten/Linq/Parsing/WhereClauseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ protected override Expression VisitBinary(BinaryExpression node)
{
if (_operators.TryGetValue(node.NodeType, out var op))
{
// This garbage is brought to you by oData
if (op == "=" && node is { Left: BinaryExpression binary, Right: ConstantExpression c } &&
(c.Type == typeof(bool) || c.Type == typeof(bool?)))
{
if (true.Equals(c.Value))
{
return VisitBinary(binary);
}
}

var left = new SimpleExpression(_members, node.Left);
var right = new SimpleExpression(_members, node.Right);

Expand Down

0 comments on commit c59545d

Please sign in to comment.