class documentation

class UpdateQuery(Query):

View In Hierarchy

An UPDATE SQL query.
Method __init__ Undocumented
Method ​_setup​_query Run on initialization and at the end of chaining. Any attributes that would normally be set in __init__() should go here instead.
Method add​_related​_update Add (name, value) to an update query for an ancestor model.
Method add​_update​_fields Append a sequence of (field, model, value) triples to the internal list that will be used to generate the UPDATE query. Might be more usefully called add_update_targets() to hint at the extra information here.
Method add​_update​_values Convert a dictionary of field name to value mappings into an update query. This is the entry point for the public update() method on querysets.
Method clone Return a copy of the current Query. A lightweight alternative to to deepcopy().
Method get​_related​_updates Return a list of query objects: one for each update required to an ancestor model. Each query will have the same filtering conditions as the current query but will only update a single table.
Method update​_batch Undocumented
Class Variable compiler Undocumented
Instance Variable related​_ids Undocumented
Instance Variable related​_updates Undocumented
Instance Variable values Undocumented

Inherited from Query:

Class Method ​_gen​_col​_aliases Undocumented
Class Method ​_gen​_cols Undocumented
Method __deepcopy__ Limit the amount of work when a Query is deepcopied.
Method __str__ Return the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string).
Method ​_add​_q Add a Q-object to the current filter.
Method ​_get​_col Undocumented
Method add​_annotation Add a single annotation expression to the Query.
Method add​_deferred​_loading No summary
Method add​_distinct​_fields Add and resolve the given fields to the query's "distinct on" clause.
Method add​_extra Add data to the various extra_* attributes for user-created additions to the query.
Method add​_fields Add the given (model) fields to the select set. Add the field names in the order specified.
Method add​_filter Undocumented
Method add​_filtered​_relation Undocumented
Method add​_immediate​_loading No summary
Method add​_ordering No summary
Method add​_q A preprocessor for the internal _add_q(). Responsible for doing final join promotion.
Method add​_select​_col Undocumented
Method add​_select​_related Set up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True).
Method append​_annotation​_mask Undocumented
Method as​_sql Responsible for returning a (sql, [params]) tuple to be included in the current query.
Method build​_filter Build a WhereNode for a single filter clause but don't add it to this Query. Query.add_q() will then add this filter to the where Node.
Method build​_filtered​_relation​_q Add a FilteredRelation object to the current filter.
Method build​_lookup Try to extract transforms and lookup from given lhs.
Method build​_where Undocumented
Method bump​_prefix No summary
Method can​_filter Return True if adding filters to this instance is still possible.
Method chain Return a copy of the current Query that's ready for another operation. The klass argument changes the type of the Query, e.g. UpdateQuery.
Method change​_aliases Change the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause.
Method check​_filterable Raise an error if expression cannot be used in a WHERE clause.
Method check​_query​_object​_type Check whether the object passed while querying is of the correct type. If not, raise a ValueError specifying the wrong object.
Method check​_related​_objects Check the type of object passed to query relations.
Method clear​_deferred​_loading Remove any fields from the deferred loading set.
Method clear​_limits Clear any existing limits.
Method clear​_ordering No summary
Method clear​_select​_clause Remove all fields from SELECT clause.
Method clear​_select​_fields Clear the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns.
Method clear​_where Undocumented
Method combine Merge the 'rhs' query into the current one (with any 'rhs' effects being applied after (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function.
Method count​_active​_tables Return the number of tables in this query with a non-zero reference count. After execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method.
Method deferred​_to​_data No summary
Method demote​_joins Change join type from LOUTER to INNER for all joins in aliases.
Method exists Undocumented
Method explain Undocumented
Method get​_aggregation Return the dictionary with the values of the existing aggregations.
Method get​_compiler Undocumented
Method get​_count Perform a COUNT() query using the current filter constraints.
Method get​_external​_cols Undocumented
Method get​_initial​_alias Return the first alias for this query, after increasing its reference count.
Method get​_loaded​_field​_names No summary
Method get​_loaded​_field​_names​_cb Callback used by get_deferred_field_names().
Method get​_meta Return the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses.
Method has​_filters Undocumented
Method has​_limit​_one Undocumented
Method has​_results Undocumented
Method is​_empty Undocumented
Method is​_nullable Check if the given field should be treated as nullable.
Method join Return an alias for the 'join', either reusing an existing alias for that join or creating a new one. 'join' is either a sql.datastructures.BaseTable or Join.
Method join​_parent​_model Make sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op.
Method names​_to​_path Walk the list of names and turns them into PathInfo tuples. A single name in 'names' can generate multiple PathInfos (m2m, for example).
Method promote​_joins Promote recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, only promote the join if it is nullable or the parent join is an outer join.
Method ref​_alias Increases the reference count for this alias.
Method relabeled​_clone Undocumented
Method reset​_refcounts Reset reference counts for aliases so that they match the value passed in to_counts.
Method resolve​_expression Provide the chance to do any preprocessing or validation before being added to the query.
Method resolve​_lookup​_value Undocumented
Method resolve​_ref Undocumented
Method rewrite​_cols Undocumented
Method set​_annotation​_mask Set the mask of annotations that will be returned by the SELECT.
Method set​_empty Undocumented
Method set​_extra​_mask Set the mask of extra select items that will be returned by SELECT. Don't remove them from the Query since they might be used later.
Method set​_group​_by Expand the GROUP BY clause required by the query.
Method set​_limits Adjust the limits on the rows retrieved. Use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, convert them to the appropriate offset and limit values.
Method set​_select Undocumented
Method set​_values Undocumented
Method setup​_joins No summary
Method solve​_lookup​_type Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains').
Method split​_exclude No summary
Method sql​_with​_params Return the query as an SQL string and the parameters that will be substituted into the query.
Method table​_alias Return a table alias for the given table_name and whether this is a new alias or not.
Method trim​_joins The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins.
Method trim​_start Trim joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins.
Method try​_transform Helper method for build_lookup(). Try to fetch and initialize a transform for name parameter from lhs.
Method unref​_alias Decreases the reference count for this alias.
Class Variable empty​_result​_set​_value Undocumented
Instance Variable ​_annotation​_select​_cache Undocumented
Instance Variable ​_extra​_select​_cache Undocumented
Instance Variable ​_filtered​_relations Undocumented
Instance Variable ​_loaded​_field​_names​_cache Undocumented
Instance Variable ​_lookup​_joins Undocumented
Instance Variable alias​_cols Undocumented
Instance Variable alias​_map Undocumented
Instance Variable alias​_prefix Undocumented
Instance Variable alias​_refcount Undocumented
Instance Variable annotation​_select​_mask Undocumented
Instance Variable annotations Undocumented
Instance Variable combinator Undocumented
Instance Variable combinator​_all Undocumented
Instance Variable combined​_queries Undocumented
Instance Variable default​_cols Undocumented
Instance Variable default​_ordering Undocumented
Instance Variable deferred​_loading Undocumented
Instance Variable distinct Undocumented
Instance Variable distinct​_fields Undocumented
Instance Variable explain​_info Undocumented
Instance Variable external​_aliases Undocumented
Instance Variable extra Undocumented
Instance Variable extra​_order​_by Undocumented
Instance Variable extra​_select​_mask Undocumented
Instance Variable extra​_tables Undocumented
Instance Variable filter​_is​_sticky Undocumented
Instance Variable group​_by Undocumented
Instance Variable high​_mark Undocumented
Instance Variable low​_mark Undocumented
Instance Variable max​_depth Undocumented
Instance Variable model Undocumented
Instance Variable order​_by Undocumented
Instance Variable select Undocumented
Instance Variable select​_for​_no​_key​_update Undocumented
Instance Variable select​_for​_update Undocumented
Instance Variable select​_for​_update​_nowait Undocumented
Instance Variable select​_for​_update​_of Undocumented
Instance Variable select​_for​_update​_skip​_locked Undocumented
Instance Variable select​_related Undocumented
Instance Variable standard​_ordering Undocumented
Instance Variable subq​_aliases Undocumented
Instance Variable subquery Undocumented
Instance Variable table​_map Undocumented
Instance Variable used​_aliases Undocumented
Instance Variable values​_select Undocumented
Instance Variable where Undocumented
Property annotation​_select Return the dictionary of aggregate columns that are not masked and should be used in the SELECT clause. Cache this result for performance.
Property base​_table Undocumented
Property extra​_select Undocumented
Property has​_select​_fields Undocumented
Property is​_sliced Undocumented
Property output​_field Return the output type of this expressions.

Inherited from BaseExpression (via Query):

Static Method ​_convert​_value​_noop Undocumented
Method __getstate__ Undocumented
Method ​_parse​_expressions Undocumented
Method ​_resolve​_output​_field Attempt to infer the output type of the expression. If the output fields of all source fields match then, simply infer the same type here. This isn't always correct, but it makes sense most of the time.
Method asc Undocumented
Method copy Undocumented
Method desc Undocumented
Method flatten Recursively yield this expression and all subexpressions, in depth-first order.
Method get​_db​_converters Undocumented
Method get​_group​_by​_cols Undocumented
Method get​_lookup Undocumented
Method get​_source​_expressions Undocumented
Method get​_source​_fields Return the underlying field types used by this aggregate.
Method get​_transform Undocumented
Method reverse​_ordering Undocumented
Method select​_format Custom format for select clauses. For example, EXISTS expressions need to be wrapped in CASE WHEN on Oracle.
Method set​_source​_expressions Undocumented
Class Variable ​_output​_field​_resolved​_to​_none Undocumented
Class Variable filterable Undocumented
Class Variable is​_summary Undocumented
Class Variable window​_compatible Undocumented
Property ​_output​_field​_or​_none Return the output field of this expression, or None if _resolve_output_field() didn't return an output type.
Property conditional Undocumented
Property contains​_aggregate Undocumented
Property contains​_column​_references Undocumented
Property contains​_over​_clause Undocumented
Property convert​_value Expressions provide their own converters because users have the option of manually specifying the output_field which may be a different type from the one the database returns.
Property field Undocumented
def __init__(self, *args, **kwargs):
def _setup_query(self):
Run on initialization and at the end of chaining. Any attributes that would normally be set in __init__() should go here instead.
def add_related_update(self, model, field, value):

Add (name, value) to an update query for an ancestor model.

Update are coalesced so that only one update query per ancestor is run.

def add_update_fields(self, values_seq):
Append a sequence of (field, model, value) triples to the internal list that will be used to generate the UPDATE query. Might be more usefully called add_update_targets() to hint at the extra information here.
def add_update_values(self, values):
Convert a dictionary of field name to value mappings into an update query. This is the entry point for the public update() method on querysets.
def clone(self):
Return a copy of the current Query. A lightweight alternative to to deepcopy().
def get_related_updates(self):
Return a list of query objects: one for each update required to an ancestor model. Each query will have the same filtering conditions as the current query but will only update a single table.
def update_batch(self, pk_list, values, using):

Undocumented

compiler: str =
related_ids =

Undocumented

related_updates: dict =

Undocumented

values: list =

Undocumented