[ 
https://issues.apache.org/jira/browse/QPID-8674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17885886#comment-17885886
 ] 

Kyrre commented on QPID-8674:
-----------------------------

Hello, sorry for the late comment.

You are absolutely correct, this is due to an error between the chair and the 
keyboard. I encountered an error in one of our selectors, and tried to boil it 
down to the simplest case I could do, and somewhere I flipped the assert.

I've looked more into this, and it seems to be the combination of brackets and 
negation.

So an updated version of the code would be:
{code:java}
     @Test
    public void originalTest() throws ParseException {
        final Filterable message = mock(Filterable.class);
        when(message.getHeader("color")).thenReturn("red");
        when(message.getHeader("price")).thenReturn(100);
        when(message.getHeader("size")).thenReturn("large");
        assertFalse(new JMSSelectorFilter("color = 'red' and not (price = 200) 
and not (size = 'small')").matches(message));
    }
  {code}
This test fails.

This boils down to

 
{code:java}
        final Filterable message = mock(Filterable.class);
        when(message.getHeader("entry")).thenReturn("bbb");
        assertFalse(new JMSSelectorFilter("true and not (false) and not 
(true)").matches(message));
 {code}
which also fails, as the matching returns true. 

But, the code
{code:java}
        final Filterable message = mock(Filterable.class);
        when(message.getHeader("entry")).thenReturn("bbb");
        assertFalse(new JMSSelectorFilter("true and (not false) and (not 
true)").matches(message));
  {code}
passes, as the matches method returns false.

 

This, as far as I can see, boils down to syntax. According to the spec, 
selectors use the select part of SQL92, but looking into this issue, I had a 
real problem finding out what the correct syntax really is.

 

The reason this is a problem for us, is that we use selectors that uses the 
'like' operator with wildcards, and have several of them chained together, 
possibly with some of them negated (in rare cases).

I don't know if this is really a bug or a mismatch/underspecification of the 
selector spec. In any case, I would like to see either both the cases returning 
the correct boolean value, or an exception thrown if the selector syntax is 
wrong.

> [Broker-J] Jms Selector Parsing - mulitple AND's
> ------------------------------------------------
>
>                 Key: QPID-8674
>                 URL: https://issues.apache.org/jira/browse/QPID-8674
>             Project: Qpid
>          Issue Type: Bug
>          Components: Broker-J
>    Affects Versions: qpid-java-broker-9.2.0
>            Reporter: Kyrre
>            Priority: Major
>         Attachments: selectorSyntax.patch
>
>
> When parsing a selector with 3 boolean expressions AND'ed together, the last 
> expression is not taken into account.
> I have attached a patch file from the latest Github version of the main 
> branch to demostrate the problem.
> In short, having a selector that evaluates (trueExpression) AND 
> (trueExpression) AND (falseExpression) evaluates to TRUE.
> Patch of JMSSelectorFilterSyntaxTest.java below.
> [^selectorSyntax.patch]
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to