Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2220

Add joins to Collection Filtering API

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.3.1
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All

      Description

      The recently added collection filtering API only goes half way in achieving a full fledged solution to filter huge collections. It still lacks joins. Look at the next two snippets:

          $criteria = Criteria::create()
              ->where(Criteria::expr()->eq('storeId', $store->getId()))
              ->andWhere(Criteria::expr()->eq('Category', 20))
              ->orderBy(array('popularity' => 'DESC'));
          return $this->BrandCategories->matching($criteria);
      

      This piece of code works but what if there is a need to filter the BrandCategories collection by Categories with some extra criteria:

          $criteria = Criteria::create()
              ->where(Criteria::expr()->eq('storeId', $store->getId()))
              ->andWhere(Criteria::expr()->eq('Category', 20))
              ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
              ->orderBy(array('popularity' => 'DESC'));
          return $this->BrandCategories->matching($criteria);
      

      That would not work.

      Ideally we should have a possibility to join other entities, the Category entity in our case here:

          $criteria = Criteria::create()
              ->where(Criteria::expr()->eq('storeId', $store->getId()))
              ->andWhere(Criteria::expr()->eq('Category', 20))
              ->innerJoin(Criteria::expr()->field('Category', 'Category'))
              ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
              ->orderBy(array('popularity' => 'DESC'));
          return $this->BrandCategories->matching($criteria);
      

      What do you think about it, does it make sense to add such functionality?

        Activity

        Oleg Namaka created issue -
        Oleg Namaka made changes -
        Field Original Value New Value
        Description The recently added collection filtering API only goes half way in achieving a full fledged solution to filter huge collections. It still lack joins. Look at the next two snippets:
        {code}
            $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('storeId', $store->getId()))
                ->andWhere(Criteria::expr()->eq('Category', 20))
                ->orderBy(array('popularity' => 'DESC'));
            return $this->BrandCategories->matching($criteria);
        {code}
        This piece of code works but what if there is a need to filter the BrandCategories collection by Categories with some extra criteria:
        {code}
            $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('storeId', $store->getId()))
                ->andWhere(Criteria::expr()->eq('Category', 20))
                ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
                ->orderBy(array('popularity' => 'DESC'));
            return $this->BrandCategories->matching($criteria);
        {code}
        That would not work.

        Ideally we should have a possibility to join other entities, the Category entity in our case here:
        {code}
            $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('storeId', $store->getId()))
                ->andWhere(Criteria::expr()->eq('Category', 20))
                ->innerJoin(Criteria::expr()->field('Category', 'Category'))
                ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
                ->orderBy(array('popularity' => 'DESC'));
            return $this->BrandCategories->matching($criteria);
        {code}

        What do you think about it, does it make sense to add such functionality?

        The recently added collection filtering API only goes half way in achieving a full fledged solution to filter huge collections. It still lacks joins. Look at the next two snippets:
        {code}
            $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('storeId', $store->getId()))
                ->andWhere(Criteria::expr()->eq('Category', 20))
                ->orderBy(array('popularity' => 'DESC'));
            return $this->BrandCategories->matching($criteria);
        {code}
        This piece of code works but what if there is a need to filter the BrandCategories collection by Categories with some extra criteria:
        {code}
            $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('storeId', $store->getId()))
                ->andWhere(Criteria::expr()->eq('Category', 20))
                ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
                ->orderBy(array('popularity' => 'DESC'));
            return $this->BrandCategories->matching($criteria);
        {code}
        That would not work.

        Ideally we should have a possibility to join other entities, the Category entity in our case here:
        {code}
            $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('storeId', $store->getId()))
                ->andWhere(Criteria::expr()->eq('Category', 20))
                ->innerJoin(Criteria::expr()->field('Category', 'Category'))
                ->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
                ->orderBy(array('popularity' => 'DESC'));
            return $this->BrandCategories->matching($criteria);
        {code}

        What do you think about it, does it make sense to add such functionality?

        Oleg Namaka made changes -
        Status Open [ 1 ] Awaiting Feedback [ 10000 ]
        Oleg Namaka made changes -
        Labels api collection filtering
        Oleg Namaka made changes -
        Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
        Oleg Namaka made changes -
        Status In Progress [ 3 ] Awaiting Feedback [ 10000 ]
        Benjamin Eberlei made changes -
        Status Awaiting Feedback [ 10000 ] Open [ 1 ]
        Hide
        Benjamin Eberlei added a comment -

        This is not a good idea, because the API has to be small to allow many different implementations, for example the in memory implementation on ArrayCollection, or the implementaiton on MongoDB ODM.

        Show
        Benjamin Eberlei added a comment - This is not a good idea, because the API has to be small to allow many different implementations, for example the in memory implementation on ArrayCollection, or the implementaiton on MongoDB ODM.
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2220, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Oleg Namaka
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: