Query: Expand the list of operators available to compare_key in WP_Meta_Query.

`compare_key`, introduced in #42409, previously supported only `=` and `LIKE`
operators. This changeset introduces a number of other operators: `!=`, `IN`,
`NOT IN`, `NOT LIKE`, `RLIKE`, `REGEXP`, `NOT REGEXP`, `EXISTS`, and `NOT EXISTS`
(the latter two aliased to `=` and `!=`, respectively). To support case-sensitive
regular expression key comparisons, the new `type_key` parameter will force
a MySQL `CAST` when 'BINARY' is passed.

Props soulseekah.
Fixes #43346.

git-svn-id: https://develop.svn.wordpress.org/trunk@46188 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2019-09-19 15:02:20 +00:00
parent 7e69921a5a
commit 6eabc83b81
4 changed files with 392 additions and 30 deletions

View File

@@ -614,6 +614,7 @@ class WP_Query {
* @since 4.6.0 Added 'post_name__in' support for `$orderby`. Introduced the `$lazy_load_term_meta` argument.
* @since 4.9.0 Introduced the `$comment_count` parameter.
* @since 5.1.0 Introduced the `$meta_compare_key` parameter.
* @since 5.3.0 Introduced the `$meta_type_key` parameter.
*
* @param string|array $query {
* Optional. Array or string of Query parameters.
@@ -655,6 +656,7 @@ class WP_Query {
* @type array $meta_query An associative array of WP_Meta_Query arguments. See WP_Meta_Query.
* @type string $meta_value Custom field value.
* @type int $meta_value_num Custom field value number.
* @type string $meta_type_key Cast for 'meta_key'. See WP_Meta_Query::construct().
* @type int $menu_order The menu order of the posts.
* @type int $monthnum The two-digit month. Default empty. Accepts numbers 1-12.
* @type string $name Post slug.