1. I don't think the seal API on the QuerySet is enough, there are other
ways implicit queries can be triggered without a QuerySet, e.g.
Book(author_id=1).author . Shai's suggestion of using a query execution
blocker is probably the best approach. If you were really worried you could
even implement it the other way round, have a permanent block and then
'unlock it' around blocks of code you expect to make queries.

2. https://github.com/YPlan/django-perf-rec is assertNumQueries on steroids
and we used it at YPlan to great success :)

3. auto-prefetch would get rid of a lot of N+1 query problems:
https://groups.google.com/forum/#!topic/django-developers/EplZGj-ejvg

On 4 January 2018 at 06:28, Shai Berger <[email protected]> wrote:

> Hi all,
>
> Django 2.0 has a new feature[1] which allows you to say "I expect no actual
> database queries in this piece of code". It is not designed to stop a
> specific
> queryset from spawning requests, so getting it to do exactly what's asked
> for
> in this thread may be a little involved, but if your goal is to prevent
> surprise queries, I think it is actually better than sealing a single
> queryset.
>
> HTH,
>         Shai
>
> [1] https://docs.djangoproject.com/en/2.0/topics/db/instrumentation/
>



-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM0E5CFQjuK3u6-npiBdZh5EcjHDP%2BciFoG7T%3DQ4nyd2AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  • Sea... 'Bryan Helmig' via Django developers (Contributions to Django itself)
    • ... Tobias McNulty
    • ... charettes
      • ... Andres Osinski
        • ... Shai Berger
          • ... Adam Johnson
            • ... charettes
          • ... Josh Smeaton
            • ... Gordon Wrigley

Reply via email to