[wp-trac] [WordPress Trac] #44658: Support BETWEEN for term names in WP_Tax_Query/WP_Term_Query

WordPress Trac noreply at wordpress.org
Wed Sep 11 15:56:51 UTC 2019


#44658: Support BETWEEN for term names in WP_Tax_Query/WP_Term_Query
-------------------------------------------------+-------------------------
 Reporter:  soulseekah                           |       Owner:  (none)
     Type:  feature request                      |      Status:  new
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Query                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  needs-testing has-unit-tests 2nd-    |     Focuses:
  opinion needs-dev-note needs-patch             |
-------------------------------------------------+-------------------------
Changes (by boonebgorges):

 * keywords:  has-patch needs-testing has-unit-tests 2nd-opinion needs-dev-
     note => needs-testing has-unit-tests 2nd-opinion needs-dev-note needs-
     patch
 * milestone:  5.3 => Future Release


Comment:

 Thanks for the patch.

 What is the use case for this? The patch is written in a way that casts
 term `name` to `SIGNED`. But this assumes a situation where term names are
 integers. This is an edge case at best. A more generic `BETWEEN` that
 allows string comparisons (ie alphabetical, based on collation) feels more
 useful.

 If we go forward with this, the `find_compatible_table_alias()` logic in
 `WP_Tax_Query::get_sql_for_clause()` should be broken out into a separate
 block so as to be reusable for `BETWEEN` and `IN`, with the actual SQL
 construction happening afterward. This'll allow us to avoid the
 `$operator` juggling in [attachment:"44658.diff"].

 We might also consider some more robust checking of the `terms` array in
 the case of `name__between`, instead of simply taking the first two values
 of the array. See eg
 https://core.trac.wordpress.org/browser/tags/5.2.3/src/wp-
 includes/date.php#L823.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44658#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list