Skip to content

Commit 625074d

Browse files
authored
Merge pull request #18 from json-api-dotnet/update-to-jadnc-v5.1.2
Update to build against JsonApiDotNetCore v5.1.2
2 parents 1fddd2e + 4ef500b commit 625074d

File tree

8 files changed

+200
-131
lines changed

8 files changed

+200
-131
lines changed

Diff for: Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworkName>net6.0</TargetFrameworkName>
44
<AspNetVersion>6.0.*</AspNetVersion>
5-
<JsonApiDotNetCoreVersion>5.1.0</JsonApiDotNetCoreVersion>
5+
<JsonApiDotNetCoreVersion>5.1.2</JsonApiDotNetCoreVersion>
66
<MongoDBDriverVersion>2.15.0</MongoDBDriverVersion>
77
<JsonApiDotNetCoreMongoDbVersionPrefix>5.1.0</JsonApiDotNetCoreMongoDbVersionPrefix>
88
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>

Diff for: src/JsonApiDotNetCore.MongoDb/Configuration/ServiceCollectionExtensions.cs

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using JsonApiDotNetCore.Queries.Internal;
77
using Microsoft.Extensions.DependencyInjection;
88

9-
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
10-
119
namespace JsonApiDotNetCore.MongoDb.Configuration;
1210

1311
public static class ServiceCollectionExtensions

Diff for: src/JsonApiDotNetCore.MongoDb/Queries/Internal/QueryableBuilding/MongoQueryableBuilder.cs

-39
This file was deleted.

Diff for: src/JsonApiDotNetCore.MongoDb/Queries/Internal/QueryableBuilding/MongoWhereClauseBuilder.cs

-46
This file was deleted.

Diff for: src/JsonApiDotNetCore.MongoDb/Repositories/MongoRepository.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using JsonApiDotNetCore.Errors;
55
using JsonApiDotNetCore.Middleware;
66
using JsonApiDotNetCore.MongoDb.Errors;
7-
using JsonApiDotNetCore.MongoDb.Queries.Internal.QueryableBuilding;
87
using JsonApiDotNetCore.MongoDb.Resources;
98
using JsonApiDotNetCore.Queries;
109
using JsonApiDotNetCore.Queries.Expressions;
@@ -115,16 +114,14 @@ protected virtual IMongoQueryable<TResource> ApplyQueryLayer(QueryLayer queryLay
115114

116115
var nameFactory = new LambdaParameterNameFactory();
117116

118-
var builder = new MongoQueryableBuilder(source.Expression, source.ElementType, typeof(Queryable), nameFactory, _resourceFactory,
117+
var builder = new QueryableBuilder(source.Expression, source.ElementType, typeof(Queryable), nameFactory, _resourceFactory,
119118
new MongoModel(_resourceGraph));
120119

121120
Expression expression = builder.ApplyQuery(queryLayer);
122121
return (IMongoQueryable<TResource>)source.Provider.CreateQuery<TResource>(expression);
123122
}
124123

125-
#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
126124
protected virtual IQueryable<TResource> GetAll()
127-
#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
128125
{
129126
return _mongoDataAccess.ActiveSession != null ? Collection.AsQueryable(_mongoDataAccess.ActiveSession) : Collection.AsQueryable();
130127
}

Diff for: test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/QueryStrings/Filtering/FilterDataTypeTests.cs

+36-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using System.Net;
23
using System.Reflection;
34
using System.Web;
@@ -49,7 +50,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
4950
});
5051

5152
string attributeName = propertyName.Camelize();
52-
string route = $"/filterableResources?filter=equals({attributeName},'{propertyValue}')";
53+
string? attributeValue = Convert.ToString(propertyValue, CultureInfo.InvariantCulture);
54+
55+
string route = $"/filterableResources?filter=equals({attributeName},'{attributeValue}')";
5356

5457
// Act
5558
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -77,7 +80,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7780
await dbContext.SaveChangesAsync();
7881
});
7982

80-
string route = $"/filterableResources?filter=equals(someDecimal,'{resource.SomeDecimal}')";
83+
string route = $"/filterableResources?filter=equals(someDecimal,'{resource.SomeDecimal.ToString(CultureInfo.InvariantCulture)}')";
8184

8285
// Act
8386
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -117,6 +120,36 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
117120
responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someGuid").With(value => value.Should().Be(resource.SomeGuid));
118121
}
119122

123+
[Fact]
124+
public async Task Can_filter_equality_on_type_DateTime_in_local_time_zone()
125+
{
126+
// Arrange
127+
var resource = new FilterableResource
128+
{
129+
SomeDateTimeInLocalZone = 27.January(2003).At(11, 22, 33, 44)
130+
};
131+
132+
await _testContext.RunOnDatabaseAsync(async dbContext =>
133+
{
134+
await dbContext.ClearTableAsync<FilterableResource>();
135+
dbContext.FilterableResources.AddRange(resource, new FilterableResource());
136+
await dbContext.SaveChangesAsync();
137+
});
138+
139+
string route = $"/filterableResources?filter=equals(someDateTimeInLocalZone,'{resource.SomeDateTimeInLocalZone:O}')";
140+
141+
// Act
142+
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
143+
144+
// Assert
145+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
146+
147+
responseDocument.Data.ManyValue.ShouldHaveCount(1);
148+
149+
responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateTimeInLocalZone")
150+
.With(value => value.Should().Be(resource.SomeDateTimeInLocalZone));
151+
}
152+
120153
[Fact]
121154
public async Task Can_filter_equality_on_type_DateTime_in_UTC_time_zone()
122155
{
@@ -191,7 +224,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
191224
await dbContext.SaveChangesAsync();
192225
});
193226

194-
string route = $"/filterableResources?filter=equals(someTimeSpan,'{resource.SomeTimeSpan}')";
227+
string route = $"/filterableResources?filter=equals(someTimeSpan,'{resource.SomeTimeSpan:c}')";
195228

196229
// Act
197230
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);

0 commit comments

Comments
 (0)