| | 24 | One remaining unanswered question is whether we want to allow returning model instances, and other flavors of return types (`values_list`, `values`). |
| | 25 | |
| | 26 | I could see us allowing the following signatures |
| | 27 | |
| | 28 | {{{#!python |
| | 29 | @overload |
| | 30 | def update( |
| | 31 | self, updates: dict, *, returning: Literal[True] | Iterable['str'] |
| | 32 | ) -> list[Model]: ... |
| | 33 | """ |
| | 34 | If `returning=True` is specified the returned model instances have all their |
| | 35 | fields selected (equivalent to `list(Model.objects.all()`) otherwise if an iterable |
| | 36 | is provided the selected fields are restricted to the specified mask (equivalent |
| | 37 | of `list(Model.objects.only(*returning))`. |
| | 38 | """ |
| | 39 | |
| | 40 | @overload |
| | 41 | def update( |
| | 42 | self, updates: dict, *, returning_values: Literal[True] | Iterable['str'] |
| | 43 | ) -> list[dict]: ... |
| | 44 | """ |
| | 45 | If `returning_values=True` is specified all the fields are returned |
| | 46 | (equivalent to `list(Model.objects.values()`) otherwise if an iterable |
| | 47 | is provided the selected fields are restricted to the specified mask (equivalent |
| | 48 | of `list(Model.objects.values(*returning))`. |
| | 49 | """ |
| | 50 | |
| | 51 | @overload |
| | 52 | def update( |
| | 53 | self, updates: dict, *, returning_values_list: Literal[True] | Iterable['str'] |
| | 54 | ) -> list[tuple]: ... |
| | 55 | """ |
| | 56 | If `returning_values_list=True` is specified all the fields are returned |
| | 57 | (equivalent to `list(Model.objects.values_list()`) otherwise if an iterable |
| | 58 | is provided the selected fields are restricted to the specified mask (equivalent |
| | 59 | of `list(Model.objects.values_list(*returning))`. |
| | 60 | """ |
| | 61 | }}} |
| | 62 | |
| | 63 | Where `returning`, `returning_values`, and `returning_values_list` are mutually exclusive. |