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

Java Driver doesn't handle regex pattern flags like CASE_INSENSITIVE

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • None
    • 3.8.2, 3.12.0, 3.12.3
    • Query Operations
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: