Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 4 years ago

#43446 closed enhancement (fixed)

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

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
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)

43446.1.diff (4.3 KB) - added by soulseekah 7 years ago.
!=, NOT LIKE, IN, NOT IN
43446.1.tests.diff (2.9 KB) - added by soulseekah 7 years ago.
Tests for !=, NOT LIKE, IN, NOT IN
43446.2.diff (5.2 KB) - added by soulseekah 7 years ago.
!=, NOT LIKE, IN, NOT IN, EXISTS, NOT EXISTS, REGEXP, NOT REGEXP, RLIKE
43446.2.tests.diff (6.0 KB) - added by soulseekah 7 years 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 7 years ago.
Docblock
43446.diff (15.2 KB) - added by boonebgorges 6 years ago.

Download all attachments as: .zip

Change History (18)

@soulseekah
7 years ago

!=, NOT LIKE, IN, NOT IN

@soulseekah
7 years ago

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

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

@soulseekah
7 years ago

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

@soulseekah
7 years ago

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

#2 @soulseekah
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...

@soulseekah
7 years ago

Docblock

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

#4 @pento
6 years ago

  • Milestone changed from 5.0 to 5.1

#5 @pento
6 years ago

  • Milestone changed from 5.1 to 5.2

Patches need review.

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

@boonebgorges
6 years ago

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

#10 @boonebgorges
6 years ago

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

Fixed in [46188].

#11 @justinahinon
5 years ago

  • Keywords has-dev-note added; needs-dev-note removed
Last edited 5 years ago by justinahinon (previous) (diff)

This ticket was mentioned in Slack in #core by pento. View the logs.


4 years ago

Note: See TracTickets for help on using tickets.