__icontains using predefined Countries after Update
Detrua opened this issue · comments
I upgraded the app from 7.2.1 to 7.3+.
Now my Method for the SELECT statment won't work anymore because it uses predefined Countries.
class CustomerManager(models.Manager):
def search_for_autocomplete(self, data):
return self.model.objects.filter(**{k + '__icontains': v for k, v in data.items()})
is equal to:
Version 7.2.1
SELECT "customers_customer"."id", "customers_customer"."created", "customers_customer"."modified", "customers_customer"."email", "customers_customer"."language", "customers_customer"."first_name", "customers_customer"."last_name", "customers_customer"."organization", "customers_customer"."landline_phone_number", "customers_customer"."mobile_phone_number", "customers_customer"."country", "customers_customer"."city", "customers_customer"."address", "customers_customer"."zip_code" FROM "customers_customer" WHERE (UPPER("customers_customer"."country"::text) LIKE UPPER(%CH%) AND UPPER("customers_customer"."language"::text) LIKE UPPER(%de%))
After Upgrade:
Version 7.3+
SELECT "customers_customer"."id", "customers_customer"."created", "customers_customer"."modified", "customers_customer"."email", "customers_customer"."language", "customers_customer"."first_name", "customers_customer"."last_name", "customers_customer"."organization", "customers_customer"."landline_phone_number", "customers_customer"."mobile_phone_number", "customers_customer"."country", "customers_customer"."city", "customers_customer"."address", "customers_customer"."zip_code" FROM "customers_customer" WHERE ("customers_customer"."country" IN (TF, MF, TW, GS, TD, CL, CX, CZ, CN, LI, PF, SX, GF, SC) AND UPPER("customers_customer"."language"::text) LIKE UPPER(%de%))
I don't know where this predefined Countries are comming from.
Previously __icontains
wasn't very useful. It was saying that your 2 character text field "contains" the text you were looking for, which doesn't really make a lot of sense.
Now, contains
, icontains
, startswith
, istartswith
, endswith
, iendswith
, regex
, iregex
all use the full country names when comparing (name
, iname
are also added to support full name "exact" matching).
I'll close this for now as working as intended. If you can identify a shortcoming in the new code that would stop some useful behaviour, then feel free to open a new ticket and reference this.