[CSHARP-1487] Linq: bad $elemMatch for discriminator of array field Created: 23/Nov/15 Updated: 07/Apr/23 Resolved: 11/Mar/16 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | 2.2.4 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Federico Ceccatto | Assignee: | Craig Wilson |
| Resolution: | Done | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
x64 Windows 7 & Windows Server 2012 R2; possibly other Win versions. |
||
| Backwards Compatibility: | Major Change |
| Description |
|
Hello, After tinkering with the underlying issue for a bit, here's a short, self-contained example:
The above code results in the following output:
The first query adds a spurious "." before "_t" which basically matches to nothing. I've attempted to trigger the same bug with other fields (array of primitive BSON numbers, array of objects, another query over the discriminator using GetType()) but I couldn't get it to manifest except for the "is" keyword. Please let me know if you need any more information. |
| Comments |
| Comment by Githook User [ 11/Mar/16 ] |
|
Author: {u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}Message: |
| Comment by Githook User [ 11/Mar/16 ] |
|
Author: {u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}Message: |
| Comment by Craig Wilson [ 27/Jan/16 ] |
|
Hi Frederico, I've reproduced this. Thanks for the report. We'll queue this up for fixing. Craig |
| Comment by Federico Ceccatto [ 09/Dec/15 ] |
|
Hi Craig, The "._t" fragment seems to be constructed in line 1519 of Linq/Translators/PredicateTranslator.cs, due to a 'true' return value from ExpressionHelper.TryGetExpression, but I cannot say whether the problem lies in the helper or directly in TranslateTypeIsQuery(). |
| Comment by Craig Wilson [ 04/Dec/15 ] |
|
Hi Federico, You said after upgrading to 2.1.1. What version did you upgrade from? Also, prior to upgrading, which of these queries were you running and what was the query that was generated? Craig |