Skip to content

Commit

Permalink
Mongo+deps: Upgrade to MongoDB.Driver 3.1.0
Browse files Browse the repository at this point in the history
There is some changes to the JSON output of the MongoDB queries,
therefore we have to accommodate our expectations for the tests.
  • Loading branch information
kennethmyhra committed Feb 1, 2025
1 parent ece1b50 commit 8da2376
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/Spark.Mongo.Tests/Search/BsonSerializationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class BsonSerializationProvider : IBsonSerializationProvider
private IDictionary<Type, Func<IBsonSerializer>> _registeredBsonSerializers = new Dictionary<Type, Func<IBsonSerializer>>
{
{ typeof(BsonNull), () => new BsonNullSerializer() },
{ typeof(string), () => new StringBsonSerializer() },
{ typeof(string), () => new StringSerializer() },
{ typeof(BsonDocument), () => new BsonDocumentSerializer() },
{ typeof(BsonDateTime), () => new BsonDateTimeSerializer() },
};
Expand All @@ -31,4 +31,4 @@ public IBsonSerializer GetSerializer(System.Type type)

return null;
}
}
}
29 changes: 15 additions & 14 deletions src/Spark.Mongo.Tests/Search/CriteriumQueryBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CriteriumQueryBuilderTests
[Theory]
[InlineData(ResourceType.Condition, "code", "code=ha125", "{ \"$or\" : [{ \"code\" : { \"$elemMatch\" : { \"code\" : \"ha125\" } } }, { \"code\" : { \"$not\" : { \"$type\" : 4 } }, \"code.code\" : \"ha125\" }, { \"$and\" : [{ \"code\" : { \"$type\" : 2 } }, { \"code\" : \"ha125\" }] }] }")]
[InlineData(ResourceType.Condition, "code", "code=|ha125", "{ \"$or\" : [{ \"code\" : { \"$elemMatch\" : { \"code\" : \"ha125\", \"system\" : { \"$exists\" : false } } } }, { \"code\" : { \"$not\" : { \"$type\" : 4 } }, \"code.code\" : \"ha125\", \"code.system\" : { \"$exists\" : false } }, { \"$and\" : [{ \"code\" : { \"$type\" : 2 } }, { \"code\" : \"ha125\" }, { \"system\" : { \"$exists\" : false } }] }] }")]
[InlineData(ResourceType.Condition, "code", "code:text=headache", "{ \"code.text\" : /headache/i }")]
[InlineData(ResourceType.Condition, "code", "code:text=headache", "{ \"code.text\" : { \"$regularExpression\" : { \"pattern\" : \"headache\", \"options\" : \"i\" } } }")]
[InlineData(ResourceType.Patient,
"gender",
"gender:not=male",
Expand Down Expand Up @@ -53,8 +53,8 @@ public void Can_Build_NumberQuery_Filter(ResourceType resourceType, string searc
}

[Theory]
[InlineData(ResourceType.Patient, "name", "name=eve", "{ \"name\" : /^eve/i }")]
[InlineData(ResourceType.Patient, "name", "name:contains=eve", "{ \"name\" : /.*eve.*/i }")]
[InlineData(ResourceType.Patient, "name", "name=eve", "{ \"name\" : { \"$regularExpression\" : { \"pattern\" : \"^eve\", \"options\" : \"i\" } } }")]
[InlineData(ResourceType.Patient, "name", "name:contains=eve", "{ \"name\" : { \"$regularExpression\" : { \"pattern\" : \".*eve.*\", \"options\" : \"i\" } } }")]
[InlineData(ResourceType.Patient, "name", "name:exact=Eve", "{ \"name\" : \"Eve\" }")]
[InlineData(ResourceType.Patient, "name", "name:missing=true", "{ \"$or\" : [{ \"name\" : { \"$exists\" : false } }, { \"name\" : null }] }")]
[InlineData(ResourceType.Patient, "name", "name:missing=false", "{ \"name\" : { \"$ne\" : null } }")]
Expand All @@ -63,7 +63,7 @@ public void Can_Build_NumberQuery_Filter(ResourceType resourceType, string searc
ResourceType.Subscription,
"criteria",
"criteria=Observation?patient.identifier=http://somehost.no/fhir/Name%20Hospital|someId",
"{ \"criteria\" : /^Observation?patient.identifier=http:\\/\\/somehost.no\\/fhir\\/Name%20Hospital|someId/i }")]
"{ \"criteria\" : { \"$regularExpression\" : { \"pattern\" : \"^Observation?patient.identifier=http://somehost.no/fhir/Name%20Hospital|someId\", \"options\" : \"i\" } } }")]
public void Can_Build_StringQuery_Filter(ResourceType resourceType, string searchParameter, string query, string expected)
{
var jsonFilter = BuildAndReturnQueryFilterAsJsonString(resourceType, searchParameter, query);
Expand All @@ -72,16 +72,17 @@ public void Can_Build_StringQuery_Filter(ResourceType resourceType, string searc
}

[Theory]
[InlineData(ResourceType.Procedure, "date", "date=2010-01-01", "{ \"date.end\" : { \"$gte\" : ISODate(\"2010-01-01T00:00:00Z\") }, \"date.start\" : { \"$lt\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=ap2010-01-01", "{ \"date.end\" : { \"$gte\" : ISODate(\"2010-01-01T00:00:00Z\") }, \"date.start\" : { \"$lt\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=eq2010-01-01", "{ \"date.end\" : { \"$gte\" : ISODate(\"2010-01-01T00:00:00Z\") }, \"date.start\" : { \"$lt\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=ne2010-01-01", "{ \"$or\" : [{ \"date.end\" : { \"$lte\" : ISODate(\"2010-01-01T00:00:00Z\") } }, { \"date.start\" : { \"$gte\" : ISODate(\"2010-01-02T00:00:00Z\") } }] }")]
[InlineData(ResourceType.Procedure, "date", "date=gt2010-01-01", "{ \"date.start\" : { \"$gte\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=ge2010-01-01", "{ \"date.start\" : { \"$gte\" : ISODate(\"2010-01-01T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=lt2010-01-01", "{ \"date.end\" : { \"$lt\" : ISODate(\"2010-01-01T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=le2010-01-01", "{ \"date.end\" : { \"$lte\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=sa2010-01-01", "{ \"date.start\" : { \"$gte\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
[InlineData(ResourceType.Procedure, "date", "date=eb2010-01-01", "{ \"date.end\" : { \"$lte\" : ISODate(\"2010-01-01T00:00:00Z\") } }")]
// { "date.end" : { "$gte" : { "$date" : "2010-01-01T00:00:00Z" } }, "date.start" : { "$lt" : { "$date" : "2010-01-02T00:00:00Z" } } }
[InlineData(ResourceType.Procedure, "date", "date=2010-01-01", "{ \"date.end\" : { \"$gte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } }, \"date.start\" : { \"$lt\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=ap2010-01-01", "{ \"date.end\" : { \"$gte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } }, \"date.start\" : { \"$lt\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=eq2010-01-01", "{ \"date.end\" : { \"$gte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } }, \"date.start\" : { \"$lt\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=ne2010-01-01", "{ \"$or\" : [{ \"date.end\" : { \"$lte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } } }, { \"date.start\" : { \"$gte\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }] }")]
[InlineData(ResourceType.Procedure, "date", "date=gt2010-01-01", "{ \"date.start\" : { \"$gte\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=ge2010-01-01", "{ \"date.start\" : { \"$gte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=lt2010-01-01", "{ \"date.end\" : { \"$lt\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=le2010-01-01", "{ \"date.end\" : { \"$lte\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=sa2010-01-01", "{ \"date.start\" : { \"$gte\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date=eb2010-01-01", "{ \"date.end\" : { \"$lte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } } }")]
[InlineData(ResourceType.Procedure, "date", "date:missing=true", "{ \"$or\" : [{ \"date\" : { \"$exists\" : false } }, { \"date\" : null }] }")]
[InlineData(ResourceType.Procedure, "date", "date:missing=false", "{ \"date\" : { \"$ne\" : null } }")]
public void Can_Build_DateQuery_Filter(ResourceType resourceType, string searchParameter, string query, string expected)
Expand Down
15 changes: 0 additions & 15 deletions src/Spark.Mongo.Tests/Search/StringBsonSerializer.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Spark.Mongo/Spark.Mongo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Hl7.Fhir.R4" Version="5.11.2" />
<PackageReference Include="MongoDB.Driver" Version="2.30.0" />
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 8da2376

Please sign in to comment.