[Django]-Django 2.0 – iexact translates to LIKE and not ILIKE

6👍

The documentations says here that the SQL equivalent of iexact is ILIKE. It doesn’t say iexact will translate in MySQL to ILIKE. That’s also not possible at all. MySQL has no ILIKE. LIKE is already case insensitive.

In PostgreSQL, which I use, iexact translates to:

SELECT ... FROM "article" WHERE UPPER("article"."title"::text) = UPPER(hello world)

The difference between exact and iexact in MySQL is the following:

  • articles = Article.objects.filter(title__iexact=’hello world’)

... WHERE `articles`.`title` LIKE hello world

  • articles = Article.objects.filter(title__exact=’hello world’)

... WHERE `articles`.`title` = hello world

👤cezar

Leave a comment