[wp-trac] [WordPress Trac] #53450: [WP_Meta_Query] Add faster LIKE based 'STARTSWITH' and 'ENDSWITH' compare modes for value query

WordPress Trac noreply at wordpress.org
Thu Jun 24 19:35:50 UTC 2021


#53450: [WP_Meta_Query] Add faster LIKE based 'STARTSWITH' and 'ENDSWITH' compare
modes for value query
-------------------------------------------------+-------------------------
 Reporter:  janthiel                             |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Query                                |     Version:  5.7.2
 Severity:  normal                               |  Resolution:
 Keywords:  dev-feedback has-patch needs-docs    |     Focuses:
  needs-codex has-unit-tests                     |  performance
-------------------------------------------------+-------------------------

Comment (by janthiel):

 @boonebgorges I agree that anything based upon the {{{LIKE}}} compare key
 feels better than introducing new keywords.
 Yet I do not believe that most users do really understand or care that the
 passed in operators for {{{compare}}} are actually SQL keywords. So
 introducing another additional subkey makes it kind of ''harder'' to use.
 Whereas the STARTSWITH and ENDSWITH keywords are very easy to get and
 document. As people will see them directly when they read about which
 compare modes are offered. So I believe offering new, easy to understand
 keywords as 1st level citizens is more ''convenient'' from a users point
 of view.

 Anyway, I also get that from a technical and architectural point of view
 it is very consequent to only support SQL keywords as 1st level compare
 keys. If we go with your suggestion - and I can absolutely support that -
 what about:

 {{{#!php
 [
   'key'                    => 'foo',
   'value'                  => 'bar'
   'compare'                => 'LIKE',
   'like_compare_mode'      => 'startswith', // (startswith | endswith |
 contains) defaults to 'contains'
 ]

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53450#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list