Skip to content

Commit 8da2376

Browse files
committed
Mongo+deps: Upgrade to MongoDB.Driver 3.1.0
There is some changes to the JSON output of the MongoDB queries, therefore we have to accommodate our expectations for the tests.
1 parent ece1b50 commit 8da2376

File tree

4 files changed

+18
-32
lines changed

4 files changed

+18
-32
lines changed

src/Spark.Mongo.Tests/Search/BsonSerializationProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class BsonSerializationProvider : IBsonSerializationProvider
1717
private IDictionary<Type, Func<IBsonSerializer>> _registeredBsonSerializers = new Dictionary<Type, Func<IBsonSerializer>>
1818
{
1919
{ typeof(BsonNull), () => new BsonNullSerializer() },
20-
{ typeof(string), () => new StringBsonSerializer() },
20+
{ typeof(string), () => new StringSerializer() },
2121
{ typeof(BsonDocument), () => new BsonDocumentSerializer() },
2222
{ typeof(BsonDateTime), () => new BsonDateTimeSerializer() },
2323
};
@@ -31,4 +31,4 @@ public IBsonSerializer GetSerializer(System.Type type)
3131

3232
return null;
3333
}
34-
}
34+
}

src/Spark.Mongo.Tests/Search/CriteriumQueryBuilderTests.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class CriteriumQueryBuilderTests
2121
[Theory]
2222
[InlineData(ResourceType.Condition, "code", "code=ha125", "{ \"$or\" : [{ \"code\" : { \"$elemMatch\" : { \"code\" : \"ha125\" } } }, { \"code\" : { \"$not\" : { \"$type\" : 4 } }, \"code.code\" : \"ha125\" }, { \"$and\" : [{ \"code\" : { \"$type\" : 2 } }, { \"code\" : \"ha125\" }] }] }")]
2323
[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 } }] }] }")]
24-
[InlineData(ResourceType.Condition, "code", "code:text=headache", "{ \"code.text\" : /headache/i }")]
24+
[InlineData(ResourceType.Condition, "code", "code:text=headache", "{ \"code.text\" : { \"$regularExpression\" : { \"pattern\" : \"headache\", \"options\" : \"i\" } } }")]
2525
[InlineData(ResourceType.Patient,
2626
"gender",
2727
"gender:not=male",
@@ -53,8 +53,8 @@ public void Can_Build_NumberQuery_Filter(ResourceType resourceType, string searc
5353
}
5454

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

7474
[Theory]
75-
[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\") } }")]
76-
[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\") } }")]
77-
[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\") } }")]
78-
[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\") } }] }")]
79-
[InlineData(ResourceType.Procedure, "date", "date=gt2010-01-01", "{ \"date.start\" : { \"$gte\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
80-
[InlineData(ResourceType.Procedure, "date", "date=ge2010-01-01", "{ \"date.start\" : { \"$gte\" : ISODate(\"2010-01-01T00:00:00Z\") } }")]
81-
[InlineData(ResourceType.Procedure, "date", "date=lt2010-01-01", "{ \"date.end\" : { \"$lt\" : ISODate(\"2010-01-01T00:00:00Z\") } }")]
82-
[InlineData(ResourceType.Procedure, "date", "date=le2010-01-01", "{ \"date.end\" : { \"$lte\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
83-
[InlineData(ResourceType.Procedure, "date", "date=sa2010-01-01", "{ \"date.start\" : { \"$gte\" : ISODate(\"2010-01-02T00:00:00Z\") } }")]
84-
[InlineData(ResourceType.Procedure, "date", "date=eb2010-01-01", "{ \"date.end\" : { \"$lte\" : ISODate(\"2010-01-01T00:00:00Z\") } }")]
75+
// { "date.end" : { "$gte" : { "$date" : "2010-01-01T00:00:00Z" } }, "date.start" : { "$lt" : { "$date" : "2010-01-02T00:00:00Z" } } }
76+
[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\" } } }")]
77+
[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\" } } }")]
78+
[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\" } } }")]
79+
[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\" } } }] }")]
80+
[InlineData(ResourceType.Procedure, "date", "date=gt2010-01-01", "{ \"date.start\" : { \"$gte\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
81+
[InlineData(ResourceType.Procedure, "date", "date=ge2010-01-01", "{ \"date.start\" : { \"$gte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } } }")]
82+
[InlineData(ResourceType.Procedure, "date", "date=lt2010-01-01", "{ \"date.end\" : { \"$lt\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } } }")]
83+
[InlineData(ResourceType.Procedure, "date", "date=le2010-01-01", "{ \"date.end\" : { \"$lte\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
84+
[InlineData(ResourceType.Procedure, "date", "date=sa2010-01-01", "{ \"date.start\" : { \"$gte\" : { \"$date\" : \"2010-01-02T00:00:00Z\" } } }")]
85+
[InlineData(ResourceType.Procedure, "date", "date=eb2010-01-01", "{ \"date.end\" : { \"$lte\" : { \"$date\" : \"2010-01-01T00:00:00Z\" } } }")]
8586
[InlineData(ResourceType.Procedure, "date", "date:missing=true", "{ \"$or\" : [{ \"date\" : { \"$exists\" : false } }, { \"date\" : null }] }")]
8687
[InlineData(ResourceType.Procedure, "date", "date:missing=false", "{ \"date\" : { \"$ne\" : null } }")]
8788
public void Can_Build_DateQuery_Filter(ResourceType resourceType, string searchParameter, string query, string expected)

src/Spark.Mongo.Tests/Search/StringBsonSerializer.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Spark.Mongo/Spark.Mongo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Hl7.Fhir.R4" Version="5.11.2" />
14-
<PackageReference Include="MongoDB.Driver" Version="2.30.0" />
14+
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

0 commit comments

Comments
 (0)