-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-4938: Support for indexing and querying on UUID and null datatype #1563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7137a1a
c6d25ad
bace726
eb81ec1
1e52e65
9ac825d
58cb351
11c89ac
4091211
2966d38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,28 @@ public void EmbeddedDocument() | |
} | ||
} | ||
|
||
[Fact] | ||
public void EqualsGuid() | ||
{ | ||
var testGuid = Guid.Parse("b52af144-bc97-454f-a578-418a64fa95bf"); | ||
|
||
var result = GetExtraTestsCollection().Aggregate() | ||
.Search(Builders<TestClass>.Search.Equals(c => c.TestGuid, testGuid)) | ||
.Single(); | ||
|
||
result.Name.Should().Be("test6"); | ||
} | ||
|
||
[Fact] | ||
public void EqualsNull() | ||
{ | ||
var result = GetExtraTestsCollection().Aggregate() | ||
.Search(Builders<TestClass>.Search.Equals(c => c.TestString, null)) | ||
.Single(); | ||
|
||
result.Name.Should().Be("testNull"); | ||
} | ||
|
||
[Fact] | ||
public void EqualsArrayField() | ||
{ | ||
|
@@ -266,6 +288,23 @@ public void In() | |
results[1].Runtime.Should().Be(31); | ||
} | ||
|
||
[Fact] | ||
public void InGuid() | ||
{ | ||
var testGuids = new[] | ||
{ | ||
Guid.Parse("b52af144-bc97-454f-a578-418a64fa95bf"), Guid.Parse("84da5d44-bc97-454f-a578-418a64fa937a") | ||
}; | ||
|
||
var result = GetExtraTestsCollection().Aggregate() | ||
.Search(Builders<TestClass>.Search.In(c => c.TestGuid, testGuids)) | ||
.Limit(10) | ||
.ToList(); | ||
|
||
result.Should().HaveCount(2); | ||
result.Select(s => s.Name).Should().BeEquivalentTo(["test6", "test7"]); | ||
} | ||
|
||
[Fact] | ||
public void MoreLikeThis() | ||
{ | ||
|
@@ -767,6 +806,10 @@ private IMongoCollection<EmbeddedMovie> GetEmbeddedMoviesCollection() => _mongoC | |
.GetDatabase("sample_mflix") | ||
.GetCollection<EmbeddedMovie>("embedded_movies"); | ||
|
||
private IMongoCollection<TestClass> GetExtraTestsCollection() => _mongoClient | ||
.GetDatabase("csharpExtraTests") | ||
.GetCollection<TestClass>("testClasses"); | ||
|
||
[BsonIgnoreExtraElements] | ||
public class Comment | ||
{ | ||
|
@@ -881,5 +924,22 @@ public class EmbeddedMovie | |
[BsonElement("score")] | ||
public double Score { get; set; } | ||
} | ||
|
||
[BsonIgnoreExtraElements] | ||
private class TestClass | ||
{ | ||
[BsonId] | ||
public ObjectId Id { get; set; } | ||
|
||
[BsonElement("name")] | ||
public string Name { get; set; } | ||
|
||
[BsonElement("testString")] | ||
public string TestString { get; set; } | ||
|
||
[BsonGuidRepresentation(GuidRepresentation.Standard)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the extra line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean to have both attributes on one line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh sorry it's all good, on the smaller laptop screen it seemed like there is an extra empty line. |
||
[BsonElement("testGuid")] | ||
public Guid TestGuid { get; set; } | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,6 +312,8 @@ public void Equals_should_render_supported_type<T>( | |
new object[] { DateTime.MinValue, "ISODate(\"0001-01-01T00:00:00Z\")", Exp(p => p.Birthday), "dob" }, | ||
new object[] { DateTimeOffset.MaxValue, "ISODate(\"9999-12-31T23:59:59.999Z\")", Exp(p => p.DateTimeOffset), nameof(Person.DateTimeOffset) }, | ||
new object[] { ObjectId.Empty, "{ $oid: '000000000000000000000000' }", Exp(p => p.Id), "_id" }, | ||
new object[] { Guid.Empty, """{ "$binary" : { "base64" : "AAAAAAAAAAAAAAAAAAAAAA==", "subType" : "04" } }""", Exp(p => p.Guid), nameof(Person.Guid) }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'Raw string literals', nice feature! TIL |
||
new object[] { null, "null", Exp(p => p.Name), nameof(Person.Name) }, | ||
new object[] { "Jim", "\"Jim\"", Exp(p => p.FirstName), "fn" } | ||
}; | ||
|
||
|
@@ -553,6 +555,7 @@ public void In_typed<T>( | |
new object[] { new[] { DateTime.MinValue, DateTime.MaxValue }, new[] { "ISODate(\"0001-01-01T00:00:00Z\")", "ISODate(\"9999-12-31T23:59:59.999Z\")" }, Exp(p => p.Birthday), "dob" }, | ||
new object[] { new[] { DateTimeOffset.MinValue, DateTimeOffset.MaxValue }, new[] { "ISODate(\"0001-01-01T00:00:00Z\")", "ISODate(\"9999-12-31T23:59:59.999Z\")" }, Exp(p => p.DateTimeOffset), nameof(Person.DateTimeOffset)}, | ||
new object[] { new[] { ObjectId.Empty, ObjectId.Parse("4d0ce088e447ad08b4721a37") }, new[] { "{ $oid: '000000000000000000000000' }", "{ $oid: '4d0ce088e447ad08b4721a37' }" }, Exp(p => p.Id), "_id" }, | ||
new object[] { new[] { Guid.Empty, Guid.Parse("b52af144-bc97-454f-a578-418a64fa95bf") }, new[] { """{ "$binary" : { "base64" : "AAAAAAAAAAAAAAAAAAAAAA==", "subType" : "04" } }""", """{ "$binary" : { "base64" : "tSrxRLyXRU+leEGKZPqVvw==", "subType" : "04" } }""" }, Exp(p => p.Guid), nameof(Person.Guid) }, | ||
new object[] { new object[] { (byte)1, (short)2, (int)3 }, new[] { "1", "2", "3" }, Exp(p => p.Object), nameof(Person.Object) } | ||
}; | ||
|
||
|
@@ -1240,7 +1243,7 @@ public class Person : SimplePerson | |
public float Float { get; set; } | ||
public double Double { get; set; } | ||
public decimal Decimal { get; set; } | ||
|
||
public Guid Guid { get; set; } | ||
public DateTimeOffset DateTimeOffset { get; set; } | ||
public TimeSpan TimeSpan { get; set; } | ||
|
||
|
@@ -1263,6 +1266,8 @@ public class Person : SimplePerson | |
public string[] Hobbies { get; set; } | ||
|
||
public object Object { get; set; } | ||
|
||
public string Name { get; set; } | ||
adelinowona marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public class Family | ||
|
Uh oh!
There was an error while loading. Please reload this page.