-
-
Notifications
You must be signed in to change notification settings - Fork 457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async queryset for Django 4.1 #1131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok as the first step, but please: take in mind that we also have special handling of .filter
and other query set methods in out plugin.
This would need to be addressed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn I was just reviewing @sobolevn 😅 making a PR with these changes
def contains(self, objs: Iterable[_T]) -> bool: ... | ||
async def acontains(self, objs: Iterable[_T]) -> bool: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this type is wrong - it doesn't take an iterable of type _T
but a single instance of _T
https://docs.djangoproject.com/en/4.1/ref/models/querysets/#django.db.models.query.QuerySet.contains
def contains(self, objs: Iterable[_T]) -> bool: ... | |
async def acontains(self, objs: Iterable[_T]) -> bool: ... | |
def contains(self, obj: _T) -> bool: ... | |
async def acontains(self, obj: _T) -> bool: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this! I never used async django, so my knowledge is limited: I was just checking that signatures are the same as regular methods.
def bulk_create( | ||
self, objs: Iterable[_T], batch_size: Optional[int] = ..., ignore_conflicts: bool = ... | ||
) -> List[_T]: ... | ||
async def abulk_create( | ||
self, objs: Iterable[_T], batch_size: Optional[int] = ..., ignore_conflicts: bool = ... | ||
) -> List[_T]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whilst modifying bulk_create
let's also import the new Django 4.1 parameters.
The update_conflicts, update_fields, and unique_fields parameters were added to support updating fields when a row insertion fails on conflict.
def bulk_create( | |
self, objs: Iterable[_T], batch_size: Optional[int] = ..., ignore_conflicts: bool = ... | |
) -> List[_T]: ... | |
async def abulk_create( | |
self, objs: Iterable[_T], batch_size: Optional[int] = ..., ignore_conflicts: bool = ... | |
) -> List[_T]: ... | |
def bulk_create( | |
self, | |
objs: Iterable[_T], | |
batch_size: Optional[int] = ..., | |
ignore_conflicts: bool = ..., | |
update_conflicts: bool = ..., | |
update_fields: Optional[Collection[str]] = ..., | |
unique_fields: Optional[Collection[str]] = ..., | |
) -> List[_T]: ... | |
async def abulk_create( | |
self, | |
objs: Iterable[_T], | |
batch_size: Optional[int] = ..., | |
ignore_conflicts: bool = ..., | |
update_conflicts: bool = ..., | |
update_fields: Optional[Collection[str]] = ..., | |
unique_fields: Optional[Collection[str]] = ..., | |
) -> List[_T]: ... |
I have made things!
I added all of asynchronous queries created in django 4.1, including
contains
created in django 4.0.Related issues
n/a