Changes between Initial Version and Version 1 of Ticket #32406, comment 23


Ignore:
Timestamp:
Mar 23, 2025, 7:26:55 PM (10 days ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • TabularUnified Ticket #32406, comment 23

    initial v1  
    1616@overload
    1717def update(
    18     self, updates: dict, *, returning: list[str] | tuple[str]
     18    self, updates: dict, *, returning: Iterable['str']
    1919) -> list[tuple]: ...
    2020}}}
     
    2222It supports SQLite, PostgreSQL, and Oracle.
    2323
     24One remaining unanswered question is whether we want to allow returning model instances, and other flavors of return types (`values_list`, `values`).
     25
     26I could see us allowing the following signatures
     27
     28{{{#!python
     29@overload
     30def 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
     41def 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
     52def 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
     63Where `returning`, `returning_values`, and `returning_values_list` are mutually exclusive.
Back to Top