[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 Jul 22 20:41:06 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 @desrosj I just uploaded the new patch. It now adds two more
properties to the Meta Query and removes the non-sql keywords for the
compare mode:
{{{
* @type string $compare_key_like_mode Search mode for
LIKE compares. Accepts 'startswith ', 'endswith' or
* 'contains'.
Default is 'contains'.
* @type string $compare_like_mode Search mode for
LIKE compares. Accepts 'startswith ', 'endswith' or
* 'contains'.
Default is 'contains'.
}}}
Those two will then select an appropriate wildcard "template" for the LIKE
/ NOT LIKE queries. It works both for value and key. I chose the naming to
be very close to the {{{$compare}}} and {{{$compare_key}}} variables to
make clear that there is a relation between both.
I also added the capability to use both properties as {{{meta_...}}} props
in the WP_Query directly. Shouldn't hurt.
I also added and extended several test cases to cover the new scenarios
and combination possibilities.
Let me know what you think.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53450#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list