Use Case
In a Drupal Commerce site, I needed to delete all products where the SKU (a textfield) is not in a list.
So I have a list like SKU_001,SKU_002,SKU_003... of all the products that I must keep.
So I need to do an SQL "NOT IN" query, then run a bulk operation on the result.
But "NOT IN" and "IN" are not available in the list of operators for a string field.
Comments
Note that it's possible to do an IN query using regex SKU_001|SKU_002|SKU_003 etc, but I believe negating an entire regex expression is hideous, and even the basic regex for IN is a lot less intuitive (and performant) for a user than standard IN and NOT IN.
As this such a basic feature, I suspect this is already built somewhere else and I didn't find it, or there's been a good reason to exclude it. I searched code,docs,contrib modules and existing issues and couldn't find anything.
So just in case I will attach my patch in the comments.
Comment | File | Size | Author |
---|---|---|---|
#1 | views-add_in_operators-1794902.patch | 1.37 KB | willieseabrook |
Comments
Comment #1
willieseabrook CreditAttribution: willieseabrook commentedComment #3
willieseabrook CreditAttribution: willieseabrook commentedah, also needed to set '#maxlength' greater (to 1000) to allow for adding in a sufficient number of items to input
let me know if this patch is useful and i'll reroll properly to pass tests