select_action
SelectAction
Bases: QueryAction
Represents a single column target for an aggregate function on a queryset.
Created when .min() / .max() / .sum() / .avg() is called,
optionally traversing relations via __. Also resolves the fields read
by column expressions (see expression_columns).
Source code in ormar/queryset/actions/select_action.py
| Python | |
|---|---|
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
expression_columns(node, model, upsert=False)
Resolve the fields an expression reads, by path from model, to the
model and table alias each one is read from, like a filter on that path.
In the update_values of an upsert (upsert=True) fields are the
model's own only, as there are no joins, and Inserted fields resolve
like F ones; anywhere else Inserted is rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
Any
|
expression node |
required |
model
|
type[Model]
|
queried model |
required |
upsert
|
bool
|
the expression is a value of an upsert's |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, SelectAction]
|
resolved field actions by field path |
Raises:
| Type | Description |
|---|---|
QueryDefinitionError
|
if a path does not lead to a non-relation
field, an upsert reads a related model or |
Source code in ormar/queryset/actions/select_action.py
| Python | |
|---|---|
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |