#43446 closed enhancement (fixed)
`meta_compare_key` should support more operators than `LIKE` and `=`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Query | Keywords: | good-first-bug has-patch has-unit-tests has-dev-note |
Focuses: | Cc: |
Description
meta_compare_key
was introduced in #42409. The default is =
and it also supports LIKE
. It could potentially support more options.
See https://core.trac.wordpress.org/ticket/42409#comment:4 and especially https://core.trac.wordpress.org/ticket/42409#comment:13 for some important considerations.
Attachments (6)
Change History (18)
#1
@
7 years ago
Started on this.
Implemented the following operators: !=
, IN
, NOT IN
, NOT LIKE
.
The numerical operators don't make too much sense, I think, since nobody names meta keys with pure numbers out there... I hope :)
I've marked EXISTS
, NOT EXISTS
(these are pretty much =
and !=
operators as is, they can probably be aliased), RLIKE
, REGEXP
and NOT REGEXP
for later, so just looking to get some eyes on what I have so far.
Special thanks to @versusbassz for working with me on this. He'll upload the modified docblock once all operators are covered.
Cheers.
#2
@
7 years ago
- Keywords has-patch has-unit-tests added; needs-patch removed
Added EXISTS
, NOT EXISTS
, REGEXP
, NOT REGEXP
, RLIKE
implementations.
Docbloc changes incoming...
#3
@
7 years ago
- Milestone changed from Awaiting Review to 5.0
- Owner set to soulseekah
- Status changed from new to assigned
Assigning to mark the good-first-bug
as "claimed."
#6
@
6 years ago
- Keywords needs-dev-note added
Latest patch still applies cleanly and needs the @since
tags updated.
@boonebgorges are you able to review this in time for 5.2?
Also, marking as needs-dev-note
so one can be drafted once the change is merged.
#7
@
6 years ago
- Milestone changed from 5.2 to 5.3
- Owner changed from soulseekah to boonebgorges
- Status changed from assigned to reviewing
Sorry for missing this when the patches came in. I don't have time to review for the 5.2 deadline, but I'll take a look for 5.3.
This ticket was mentioned in Slack in #core by sergey. View the logs.
6 years ago
#9
@
6 years ago
@soulseekah - Thanks so much for your work on this patch. I've reviewed it and I think it's strong. 43446.diff makes a few code formatting and documentation changes.
I'd like to propose that we do not include EXISTS
and NOT EXISTS
. The semantics of EXISTS
suggests to me something less specific than =
- as in the case of key = foo && compare = EXISTS
, where you're omitting the value
- but there's no corresponding "less specific" query in the case of keys. All rows in the meta table have a key
. It just feels a little confusing to me. Perhaps others don't share my intuition - I'm happy to be overruled. In that case, I might make the =
and !=
aliases clearer in the documentation.
This should be doable for 5.3, but I'll hold off a week or two in case someone wants to review or comment before the beta.
#11
@
5 years ago
- Keywords has-dev-note added; needs-dev-note removed
Mentioned in https://make.wordpress.org/core/2019/10/15/expanded-meta-key-comparison-operators-in-5-3
props @boonebgorges for the note
!=, NOT LIKE, IN, NOT IN