mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-11 10:30:58 +00:00
Merge branch 'kaedroho-issue-1276b'
This commit is contained in:
commit
c26e3c1910
4 changed files with 24 additions and 6 deletions
|
|
@ -34,6 +34,7 @@ Changelog
|
|||
* Fix: Search no longer crashes when auto-indexing a model that doesn't have an id field (Scot Hacker)
|
||||
* Fix: The `wagtailfrontendcache` module's HTTP backend has been rewritten to reliably direct requests to the configured cache hostname
|
||||
* Fix: Resizing single pixel images with the "fill" filter no longer raises "ZeroDivisionError" or "tile cannot extend outside image"
|
||||
* Fix: The queryset returned from `search` operations when using the database search backend now correctly preserves additional properties of the original query, such as `prefetch_related` / `select_related`
|
||||
|
||||
|
||||
1.0 (16.07.2015)
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ Bug fixes
|
|||
* Search no longer crashes when auto-indexing a model that doesn't have an ``id`` field
|
||||
* The ``wagtailfrontendcache`` module's HTTP backend has been rewritten to reliably direct requests to the configured cache hostname
|
||||
* Resizing single pixel images with the "fill" filter no longer raises "ZeroDivisionError" or "tile cannot extend outside image"
|
||||
* The queryset returned from ``search`` operations when using the database search backend now correctly preserves additional properties of the original query, such as ``prefetch_related`` / ``select_related``
|
||||
|
||||
|
||||
Upgrade considerations
|
||||
|
|
|
|||
|
|
@ -410,3 +410,17 @@ class TestSpecificQuery(TestCase):
|
|||
Page.objects.get(url_path='/home/events/christmas/').specific,
|
||||
Page.objects.get(url_path='/home/events/').specific,
|
||||
Page.objects.get(url_path='/home/about-us/').specific])
|
||||
|
||||
def test_specific_query_with_search(self):
|
||||
# 1276 - The database search backend didn't return results with the
|
||||
# specific type when searching a specific queryset.
|
||||
|
||||
pages = list(Page.objects.specific().live().in_menu().search(None, backend='wagtail.wagtailsearch.backends.db'))
|
||||
|
||||
# Check that each page is in the queryset with the correct type.
|
||||
# We don't care about order here
|
||||
self.assertEqual(len(pages), 4)
|
||||
self.assertIn(Page.objects.get(url_path='/home/other/').specific, pages)
|
||||
self.assertIn(Page.objects.get(url_path='/home/events/christmas/').specific, pages)
|
||||
self.assertIn(Page.objects.get(url_path='/home/events/').specific, pages)
|
||||
self.assertIn(Page.objects.get(url_path='/home/about-us/').specific, pages)
|
||||
|
|
|
|||
|
|
@ -22,10 +22,12 @@ class DBSearchQuery(BaseSearchQuery):
|
|||
|
||||
return q
|
||||
|
||||
def get_q(self):
|
||||
# Get filters as a q object
|
||||
q = self._get_filters_from_queryset()
|
||||
def get_extra_q(self):
|
||||
# Run _get_filters_from_queryset to test that no fields that are not
|
||||
# a FilterField have been used in the query.
|
||||
self._get_filters_from_queryset()
|
||||
|
||||
q = models.Q()
|
||||
model = self.queryset.model
|
||||
|
||||
if self.query_string is not None:
|
||||
|
|
@ -57,10 +59,10 @@ class DBSearchQuery(BaseSearchQuery):
|
|||
|
||||
class DBSearchResults(BaseSearchResults):
|
||||
def get_queryset(self):
|
||||
model = self.query.queryset.model
|
||||
q = self.query.get_q()
|
||||
queryset = self.query.queryset
|
||||
q = self.query.get_extra_q()
|
||||
|
||||
return model.objects.filter(q).distinct()[self.start:self.stop]
|
||||
return queryset.filter(q).distinct()[self.start:self.stop]
|
||||
|
||||
def _do_search(self):
|
||||
return self.get_queryset()
|
||||
|
|
|
|||
Loading…
Reference in a new issue