Support additional IndexOf comparisons to -1 and 0

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: 3.6.0
    • Component/s: LINQ
    • None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      The following `Where` statements are translated to a `$match` stage using `$expr` filter:

       

      queryable.Where(x.S.IndexOf("a") == -1)
      queryable.Where(x.S.IndexOf("a") != -1) 
      queryable.Where(x.S.IndexOf("a") < 0)
      queryable.Where(x.S.IndexOf("a") >= 0

       

      but could be translated more efficiently using regular expressions.

      The existing support for translating `IndexOf` comparisons to regular expressions only supports `==` and `!=" and only when compared to non-negative integers.

      One approach to implement this would be to modify the existing code, but the existing code is complicated (because it handles lots of scenarios) and care would have to be taken to not break anything. If that proves difficult, it might be easier to implement these 4 cases with an entirely new code path.

       

            Assignee:
            Unassigned
            Reporter:
            Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: