This repository has been archived by the owner on Oct 22, 2019. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for a lovely project! I hopefully have a small improvement to contribute.
Mommy makes a database call when calling
prepare
on a recipe with a sequence. Usually, our aim when usingprepare
is to avoid database queries as they're slow. I dug into the code to find out why this call gets made, and I think it's avoidable.--
If I'm not mistaken, the intention of this bit of code is to store a backup copy of the given iterator while being able to iterate through it for this
make()
orprepare()
call. We need to detect if this is the first run, so we check if any instances are present or if the dictionary is empty.This causes a problem when using
prepare()
, because it still does a call to the database - something we usually don't want when usingprepare()
. If I'm not mistaken, we can safely switch the statement around, which avoids the call to the database.To be honest, my gut feeling is that the call to
m.objects.count()
can be avoided all together - the existing logic should be sufficient. But I'm playing it safe here ;)