Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2051

after filtering an association by using ->matching(Criteria) original association changes

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      after filtering an association with a criteria it changes so it's not a normal collection and you can't re-filter it.

      even after hydrating it you can't filter it.

        Activity

        Koby Soto created issue -
        Koby Soto made changes -
        Field Original Value New Value
        Fix Version/s 2.4 [ 10321 ]
        Hide
        Koby Soto added a comment -

        The filtering only works once and only if the database hasn't been queried!

        This is a major bug because i would like to filter big collections more than once per request.

        Show
        Koby Soto added a comment - The filtering only works once and only if the database hasn't been queried! This is a major bug because i would like to filter big collections more than once per request.
        Koby Soto made changes -
        Status Open [ 1 ] Awaiting Feedback [ 10000 ]
        Hide
        Benjamin Eberlei added a comment -

        Can you add a code example? I don't understand what you mean.

        Show
        Benjamin Eberlei added a comment - Can you add a code example? I don't understand what you mean.
        Hide
        Koby Soto added a comment -

        sure: here's just an example (written right now to demonstrate, not taken from real project, so no criticize pls):

        Let's say we have two functions:

        1. function getExpensiveBooks($limit)

        { $books = $this->getBooks(); //proxy, haven't queried yet. $criteria = Criteria::create()->where(Criteria::expr()->gt('price', '10'))->setMaxResults($limit); return $books->matching($criteria); }

        2. function getCheapBooks($limit)

        { $books = $this->getBooks(); //proxy, haven't queried yet. $criteria = Criteria::create()->where(Criteria::expr()->lt('price', '4'))->setMaxResults($limit); return $books->matching($criteria); }

        now, let's say that in the controller i've called:
        $expensiveBooks = $author->getExpensiveBooks(3); //will work fine, and the query will be according the criteria.
        //but going on and doing this:
        $cheapBooks = $author->getCheapBooks(3); //will not work: matching is undefined function.

        It appears that doing matching only works on the first time on a certain association.

        Show
        Koby Soto added a comment - sure: here's just an example (written right now to demonstrate, not taken from real project, so no criticize pls): Let's say we have two functions: 1. function getExpensiveBooks($limit) { $books = $this->getBooks(); //proxy, haven't queried yet. $criteria = Criteria::create()->where(Criteria::expr()->gt('price', '10'))->setMaxResults($limit); return $books->matching($criteria); } 2. function getCheapBooks($limit) { $books = $this->getBooks(); //proxy, haven't queried yet. $criteria = Criteria::create()->where(Criteria::expr()->lt('price', '4'))->setMaxResults($limit); return $books->matching($criteria); } now, let's say that in the controller i've called: $expensiveBooks = $author->getExpensiveBooks(3); //will work fine, and the query will be according the criteria. //but going on and doing this: $cheapBooks = $author->getCheapBooks(3); //will not work: matching is undefined function. It appears that doing matching only works on the first time on a certain association.
        Koby Soto made changes -
        Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
        Hide
        Koby Soto added a comment -

        this was due to inconsistent association type in both owner and target (target had one-to-one while owner had one-to-many)

        sorry

        Show
        Koby Soto added a comment - this was due to inconsistent association type in both owner and target (target had one-to-one while owner had one-to-many) sorry
        Koby Soto made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]

        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-2051, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Koby Soto
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: