Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3708

Java Driver doesn't handle regex pattern flags like CASE_INSENSITIVE

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.8.2, 3.12.0, 3.12.3
    • Component/s: Query Operations
    • None

      com.mongodb.client.model.Filters.regex(String fieldName, Pattern pattern) doesn't respect options like CASE_INSENSITIVE. 

      Pattern p = Pattern.compile("(.)" + name.toLowerCase() + "(.)", Pattern.CASE_INSENSITIVE);
      FindIterable<MongoEvent> me = collection.find(Filters.regex("name", p));

      if translated to this command:

      '{ "find" : "test.test_account", "filter" : { "name" : { "$regularExpression" :

      { "pattern" : "(.*)s1lvcvky(.*)", "options" : "" }

      } } }'

      So, upgrading my driver wrapper broke everything because compiled Pattern regular expressions are no longer supported properly.  Driver wrapper doesn't support regex options, ie regex(String fieldName, String pattern, String options).

      Only related bug I found had to do with Pattern codec tests.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            tad.yeager@gmail.com Tad Yeager
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: