Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3174

Query Cache not correct working when using SQLFilter

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.1
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:

      Description

      We have an SQLFilter to filter on entities with a specific Trait implemented. The filter is very easy:

      $res = $targetTableAlias . '.agency_id = ' . $this->getCurrentAgencyId();

      On our system we have the query cache enabled, this works as long the "AgencyId" doesn't change. When the ID changes, the query cache seems to return the wrong (old cache) query.

        Activity

        Hide
        Marco Pivetta added a comment -

        I'm not sure if this case should be contemplated by the ORM. Filters are low-level and supposed to be stateless (services).

        Show
        Marco Pivetta added a comment - I'm not sure if this case should be contemplated by the ORM. Filters are low-level and supposed to be stateless (services).
        Hide
        Benno Eggnauer added a comment -

        OK, we can disable the query cache for this case. But then should at least the documentation be updated, which explicitly mentions to use filter for locales, which are also not stateless: http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html#example-filter-class

        Also in the query cache chapter: http://doctrine-orm.readthedocs.org/en/latest/reference/caching.html#query-cache

        It is highly recommended that in a production environment you cache the transformation of a DQL query to its SQL counterpart. It doesn’t make sense to do this parsing multiple times as it doesn’t change unless you alter the DQL query.

        Show
        Benno Eggnauer added a comment - OK, we can disable the query cache for this case. But then should at least the documentation be updated, which explicitly mentions to use filter for locales, which are also not stateless: http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html#example-filter-class Also in the query cache chapter: http://doctrine-orm.readthedocs.org/en/latest/reference/caching.html#query-cache It is highly recommended that in a production environment you cache the transformation of a DQL query to its SQL counterpart. It doesn’t make sense to do this parsing multiple times as it doesn’t change unless you alter the DQL query.
        Hide
        Marco Pivetta added a comment -

        Benno Eggnauer can you eventually provide a pull request?

        Show
        Marco Pivetta added a comment - Benno Eggnauer can you eventually provide a pull request?
        Hide
        James Blizzard added a comment -

        I would just like to say that we're having exactly the same issue. I'd love some method (official or not) of having filters being taken into account in this situation.

        Show
        James Blizzard added a comment - I would just like to say that we're having exactly the same issue. I'd love some method (official or not) of having filters being taken into account in this situation.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Benno Eggnauer
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: