Hi Nicola,

Without a lot of familiarity of SearchQuery, in particular, it looks like a 
bug to me. SearchQuery defines its own operators to work around the 
limitation in Combinable, but fails to take into account that when two 
SearchQuery instances are combined, you're returned a CombinedExpression 
(containing SearchQueries). SearchVector *does* take this into 
consideration though, and provides it's own Combinable Mixin, so I wonder 
if the limitations for SearchQuery aren't on purpose.

Marc Tamlyn would probably have a good idea if this was an oversight or 
deliberate.

The fix would be to define a SearchQueryCombinable Mixin that looks very 
similar to SearchVectorCombinable, and override the various __or__ and 
__and__ methods, as the SearchQuery type does itself. Hope that helps?

Regards,

On Thursday, 25 August 2016 21:30:06 UTC+10, Nicola wrote:
>
> Dear Django-Developers,
>
> We just started using the new search ability that landed in Django 1.10 
> (using postgres).
>
> Reading the documentation[1], I thought I can use `&` and `|` to join 
> search queries as I like[2]. This is not the case, which can easily be seen 
> by creating a the test-case with two ampersands or pipes[3]. 
>
> I would not expect that the test-cases pass, but they error out: 
> `NotImplementedError: Use .bitand() and .bitor() for bitwise logical 
> operations.`.
>
> To me this is not the expected behaviour, but maybe I deducted the wrong 
> conclusions from reading the documentation.
>
> My unanswered questions:
>
>    - Is it a bug?
>    - Is this the intended behaviour?
>       - If so: what needs to be done to get a note into the 
>       documentation, that only one ampersand/pipe is allowed?
>    
> Thank you for your time and effort for this excellent framework!
>
> Kind Regards,
>
> Nicola
>
>
> [1]: 
> https://docs.djangoproject.com/en/1.10/topics/db/search/#postgresql-support 
> and https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/search/
> [2]: 
> https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/search/#searchquery
> [3]: https://github.com/django/django/compare/master...hixi:master
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/31548201-3d01-4318-8165-47cad2afa1fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to