etianen / django-watson

Full-text multi-table search application for Django. Easy to install and use, with good performance.
BSD 3-Clause "New" or "Revised" License
1.2k stars 129 forks source link

[BUGFIX] #255 Fixed MySQL tests failing mysql + admin context #261

Closed krukas closed 4 years ago

krukas commented 4 years ago

The admin tests failed because of the following error:

(admin.E404) 'django.contrib.messages.context_processors.messages' must be enabled in DjangoTemplates (TEMPLATES) in order to use the admin application.

This is fixed by adding 'django.contrib.messages.context_processors.messages' tot the context_processors

The MySQL tests failed on the error:

django.db.utils.OperationalError: (1055, "Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test_test_project.watson_searchentry.title' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by")

After some diging this hapens because the qeuryset count uses an annotation/aggrogation. https://github.com/django/django/blob/37f8f293775d0b672da8ae369d9a4e17f1db7851/django/db/models/sql/query.py#L510

Based on what django recomends for setting the sql_mode to https://docs.djangoproject.com/en/2.2/ref/databases/#setting-sql-mode. And the recomandation from https://code.djangoproject.com/ticket/15940#comment:10 to always explicitly set the sql_mode.

I have updated the test MySQL settings to set the sql_mode to STRICT_TRANS_TABLES

etianen commented 4 years ago

Brilliant! Thanks for looking into this. I'll get a release out.

etianen commented 4 years ago

1.5.3 is out