WordPress.org

Make WordPress Core

Opened 19 months ago

Closed 40 hours ago

#43446 closed enhancement (fixed)

`meta_compare_key` should support more operators than `LIKE` and `=`

Reported by: boonebgorges Owned by: boonebgorges
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Query Keywords: good-first-bug has-patch has-unit-tests needs-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)

43446.1.diff (4.3 KB) - added by soulseekah 19 months ago.
!=, NOT LIKE, IN, NOT IN
43446.1.tests.diff (2.9 KB) - added by soulseekah 19 months ago.
Tests for !=, NOT LIKE, IN, NOT IN
43446.2.diff (5.2 KB) - added by soulseekah 19 months ago.
!=, NOT LIKE, IN, NOT IN, EXISTS, NOT EXISTS, REGEXP, NOT REGEXP, RLIKE
43446.2.tests.diff (6.0 KB) - added by soulseekah 19 months ago.
Tests for !=, NOT LIKE, IN, NOT IN, EXISTS, NOT EXISTS, REGEXP, NOT REGEXP, RLIKE
43446.2.doc.diff (3.2 KB) - added by soulseekah 19 months ago.
Docblock
43446.diff (15.2 KB) - added by boonebgorges 10 days ago.

Download all attachments as: .zip

Change History (16)

@soulseekah
19 months ago

!=, NOT LIKE, IN, NOT IN

@soulseekah
19 months ago

Tests for !=, NOT LIKE, IN, NOT IN

#1 @soulseekah
19 months 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.

@soulseekah
19 months ago

!=, NOT LIKE, IN, NOT IN, EXISTS, NOT EXISTS, REGEXP, NOT REGEXP, RLIKE

@soulseekah
19 months ago

Tests for !=, NOT LIKE, IN, NOT IN, EXISTS, NOT EXISTS, REGEXP, NOT REGEXP, RLIKE

#2 @soulseekah
19 months ago

  • Keywords has-patch has-unit-tests added; needs-patch removed

Added EXISTS, NOT EXISTS, REGEXP, NOT REGEXP, RLIKE implementations.

Docbloc changes incoming...

@soulseekah
19 months ago

Docblock

#3 @SergeyBiryukov
19 months 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."

#4 @pento
11 months ago

  • Milestone changed from 5.0 to 5.1

#5 @pento
9 months ago

  • Milestone changed from 5.1 to 5.2

Patches need review.

#6 @desrosj
6 months 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 @boonebgorges
6 months 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.


5 weeks ago

@boonebgorges
10 days ago

#9 @boonebgorges
10 days 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.

#10 @boonebgorges
40 hours ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

Fixed in [46188].

Note: See TracTickets for help on using tickets.