from psycopg2.extensions import adapt
from django.contrib.postgres.search import SearchQuery


class PrefixedPhraseQuery(SearchQuery):
    """
    Alter the tsquery executed by SearchQuery
    """

    def __init__(self, value, search_type="raw", all_partial=False, **kwargs):
        # all_partial=True puts :* after every term, otherwise only the last term is partial
        self.all_partial = all_partial
        glue = ":* & " if self.all_partial else " & "
        value_prefix = "%s:*" % glue.join(value.split())
        super(PrefixedPhraseQuery, self).__init__(
            value_prefix, search_type=search_type, **kwargs
        )

7e0be1a18e64f991f1570fa68358bd6919bbf4f3
<mask token>


class PrefixedPhraseQuery(SearchQuery):
    <mask token>
    <mask token>

<mask token>


class PrefixedPhraseQuery(SearchQuery):
    <mask token>

    def __init__(self, value, search_type='raw', all_partial=False, **kwargs):
        self.all_partial = all_partial
        glue = ':* & ' if self.all_partial else ' & '
        value_prefix = '%s:*' % glue.join(value.split())
        super(PrefixedPhraseQuery, self).__init__(value_prefix, search_type
            =search_type, **kwargs)

<mask token>


class PrefixedPhraseQuery(SearchQuery):
    """
    Alter the tsquery executed by SearchQuery
    """

    def __init__(self, value, search_type='raw', all_partial=False, **kwargs):
        self.all_partial = all_partial
        glue = ':* & ' if self.all_partial else ' & '
        value_prefix = '%s:*' % glue.join(value.split())
        super(PrefixedPhraseQuery, self).__init__(value_prefix, search_type
            =search_type, **kwargs)

from psycopg2.extensions import adapt
from django.contrib.postgres.search import SearchQuery


class PrefixedPhraseQuery(SearchQuery):
    """
    Alter the tsquery executed by SearchQuery
    """

    def __init__(self, value, search_type='raw', all_partial=False, **kwargs):
        self.all_partial = all_partial
        glue = ':* & ' if self.all_partial else ' & '
        value_prefix = '%s:*' % glue.join(value.split())
        super(PrefixedPhraseQuery, self).__init__(value_prefix, search_type
            =search_type, **kwargs)

from psycopg2.extensions import adapt
from django.contrib.postgres.search import SearchQuery


class PrefixedPhraseQuery(SearchQuery):
    """
    Alter the tsquery executed by SearchQuery
    """

    def __init__(self, value, search_type="raw", all_partial=False, **kwargs):
        # all_partial=True puts :* after every term, otherwise only the last term is partial
        self.all_partial = all_partial
        glue = ":* & " if self.all_partial else " & "
        value_prefix = "%s:*" % glue.join(value.split())
        super(PrefixedPhraseQuery, self).__init__(
            value_prefix, search_type=search_type, **kwargs
        )
