Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-9687

Add RLIKE to Search Builder operators list

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.8, 4.0.8, 4.1.0
    • Fix Version/s: 4.2.0
    • Component/s: CiviCRM Search
    • Labels:
      None

      Description

      RLIKE is a very useful MySQL operator that allows regular expression matches on fields. One use case that came up recently was a request to search for contacts in ZIP code prefixes 940,941,942,943,944,949 (but not 945,946,947,948).

      With the regular LIKE operator, this is a rather tedious Search Builder query with five "Also include..." clauses:
      LIKE 940%
      LIKE 941%
      LIKE 942%
      LIKE 943%
      LIKE 944%
      LIKE 949%

      With RLIKE, we can use a single clause with a simple regex to match just the required prefixes:
      RLIKE 94[012349]..

      I'm sure there are many other use cases, and it's a simple change to CRM/Core/BAO/Mapping.php

        Attachments

        1. RLIKE_Operator.patch
          1 kB
          Jim Meehan
        2. SearchBuilderTest.php
          5 kB
          jason bertolacci

          Activity

            People

            • Assignee:
              dgg David Greenberg
              Reporter:
              jcm55 Jim Meehan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 10 minutes
                10m
                Remaining:
                Remaining Estimate - 10 minutes
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified