From b3bf2415d2b1debb8b44cb140d8de10d431d1fa0 Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Fri, 24 Nov 2017 05:09:39 +0100 Subject: [PATCH] Fixes PostgreSQL tests. --- wagtail/contrib/postgres_search/backend.py | 3 ++- wagtail/contrib/postgres_search/models.py | 2 ++ wagtail/wagtailcore/models.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wagtail/contrib/postgres_search/backend.py b/wagtail/contrib/postgres_search/backend.py index 0429ecbd2..1d750c96a 100644 --- a/wagtail/contrib/postgres_search/backend.py +++ b/wagtail/contrib/postgres_search/backend.py @@ -209,7 +209,8 @@ class PostgresSearchQueryCompiler(BaseSearchQueryCompiler): else: sub_field_name = None for field in fields: - if field.field_name == field_name: + if isinstance(field, SearchField) \ + and field.field_name == field_name: # Note: Searching on a specific related field using # `.search(fields=…)` is not yet supported by Wagtail. # This method anticipates by already implementing it. diff --git a/wagtail/contrib/postgres_search/models.py b/wagtail/contrib/postgres_search/models.py index 8bb85dee0..798eaaddb 100644 --- a/wagtail/contrib/postgres_search/models.py +++ b/wagtail/contrib/postgres_search/models.py @@ -14,6 +14,8 @@ from .utils import get_descendants_content_types_pks class TextIDGenericRelation(GenericRelation): + auto_created = True + def get_content_type_lookup(self, alias, remote_alias): field = self.remote_field.model._meta.get_field( self.content_type_field_name) diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index 84688cd5d..c5707e27a 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -1035,7 +1035,7 @@ class Page(six.with_metaclass(PageBase, AbstractPage, index.Indexed, Clusterable def copy(self, recursive=False, to=None, update_attrs=None, copy_revisions=True, keep_live=True, user=None): # Fill dict with self.specific values specific_self = self.specific - default_exclude_fields = ['id', 'path', 'depth', 'numchild', 'url_path', 'path'] + default_exclude_fields = ['id', 'path', 'depth', 'numchild', 'url_path', 'path', 'index_entries'] exclude_fields = default_exclude_fields + specific_self.exclude_fields_in_copy specific_dict = {}