Skip to content

Not enough parenthesis when using not() ? #562

@greg0ire

Description

@greg0ire

I'm trying to link an article document with other articles. I'd rather not link an article with itself, so I try to write my first ODM query, with the helper in sonata admin :

$this->createQuery()
                            ->where()
                                ->not()
                                    ->same($this->getSubject()->getId(), 'a')
                                ->end()
                            ->end()
                        ->getQuery()

This produces the following query:

SELECT * FROM [nt:unstructured] AS a 
               WHERE (
                     NOT 
                           ISSAMENODE(a, ['/articles/mon deuxieme article']) 
                    AND 
                           (a.[phpcr:class] = 'Cine\DbBundle\Document\Article' OR a.[phpcr:classparents] = 'Cine\DbBundle\Document\Article'))

The AND operator seems to have higher priority because I can get what I want when trying the following request :

SELECT * FROM [nt:unstructured] AS a 
               WHERE (
                     (NOT 
                           ISSAMENODE(a, ['/articles/mon deuxieme article']) )
                    AND 
                           (a.[phpcr:class] = 'Cine\DbBundle\Document\Article' OR a.[phpcr:classparents] = 'Cine\DbBundle\Document\Article'))

Notice the extra couple of parenthesis.

  1. I think this is a bug
  2. I would like to know if I could somehow generate the second request with the query builder

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions