`_bulk_create` without `_quantity` will be ignored
e.g.: baker.make(MyModel, _bulk_create=True) will no use bulk create, because _quantity can't be None, so _bulk_create will be just ignored, see:
https://github.com/model-bakers/model_bakery/blob/38d2dd797832adcd2523048830d0843732acd9c4/model_bakery/baker.py#L126-L127
I think it's not very much to do, to support this case, isn't it? I can create a PR, if this is ok.
Versions
- Model Bakery 1.17.0
what's the expected behavior? raising exception mentioning that _quantity should be specified?
Hi @jedie,
Sorry it took so long to get back to this issue!
I'm trying to understand your use case better. When you call baker.make(MyModel, _bulk_create=True) without _quantity, what would be your expected behavior?
A few possibilities I can think of:
- Create a single object using
bulk_create()(equivalent to_quantity=1, _bulk_create=True) - I presume that is what you expected? - Raise an error/warning that
_bulk_createrequires passing_quantity
Could you help clarify what your use case is and what you'd expect to happen? This will help us align on the right solution.
If you're still interested in providing a PR for this, that would be very welcome! Otherwise, once we agree on the expected behavior, we can implement it.
Thanks for bringing this up!
I am happy to get back to it and reopen; feel free to post a reply!
Create a single object using bulk_create() (equivalent to _quantity=1, _bulk_create=True) - I presume that is what you expected?
Yes, this is it. Think it was about to skip signal handling on creation. But can't remember...
(I have no permission to reopen this issue ;)