class documentation

class UpdateQuery(Query): (source)

View In Hierarchy

An UPDATE SQL query.

Method __init__ Undocumented
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 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
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.

Inherited from Query:

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_annotation Add a single annotation expression to the Query.
Method add_deferred_loading Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. Add the new field names to any existing field names that are deferred (or removed from any existing field names that are marked as the only ones for immediate loading).
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 Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, remove those names from the new field_names before storing the new names for immediate loading...
Method add_ordering Add items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions.
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 Change the alias prefix to the next letter in the alphabet in a way that the other query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call...
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_alias Undocumented
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 Remove any ordering settings if the current query allows it without side effects, set 'force' to True to clear the ordering regardless. If 'clear_default' is True, there will be no ordering in the resulting query (not even the model's default).
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 Convert the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work out which fields are being initialized on each model...
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_group_by_cols Undocumented
Method get_initial_alias Return the first alias for this query, after increasing its reference count.
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 base_table_class or join_class.
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 Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for the table to start the joining from.
Method solve_lookup_type Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains').
Method split_exclude When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first N-to-many relation field.
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 combinator Undocumented
Class Variable combinator_all Undocumented
Class Variable combined_queries Undocumented
Class Variable empty_result_set_value Undocumented
Class Variable explain_info Undocumented
Class Variable extra_tables Undocumented
Class Variable filter_is_sticky Undocumented
Class Variable max_depth Undocumented
Class Variable select_for_no_key_update Undocumented
Class Variable select_for_update Undocumented
Class Variable select_for_update_nowait Undocumented
Class Variable select_for_update_of Undocumented
Class Variable select_for_update_skip_locked Undocumented
Class Variable standard_ordering Undocumented
Class Variable subquery 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 default_cols Undocumented
Instance Variable default_ordering Undocumented
Instance Variable deferred_loading Undocumented
Instance Variable distinct Undocumented
Instance Variable distinct_fields Undocumented
Instance Variable external_aliases Undocumented
Instance Variable extra Undocumented
Instance Variable extra_order_by Undocumented
Instance Variable extra_select_mask Undocumented
Instance Variable group_by Undocumented
Instance Variable high_mark Undocumented
Instance Variable low_mark Undocumented
Instance Variable model Undocumented
Instance Variable order_by Undocumented
Instance Variable select Undocumented
Instance Variable select_related Undocumented
Instance Variable subq_aliases 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.
Class Method _gen_col_aliases Undocumented
Class Method _gen_cols Undocumented
Method _add_q Add a Q-object to the current filter.
Method _get_col Undocumented
Instance Variable _annotation_select_cache Undocumented
Instance Variable _extra_select_cache Undocumented
Instance Variable _filtered_relations Undocumented
Instance Variable _lookup_joins Undocumented

Inherited from BaseExpression (via Query):

Method __getstate__ Undocumented
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_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 prefix_references Undocumented
Method replace_references 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 filterable Undocumented
Class Variable is_summary Undocumented
Class Variable window_compatible Undocumented
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
Static Method _convert_value_noop Undocumented
Method _parse_expressions Undocumented
Method _resolve_output_field Attempt to infer the output type of the expression.
Class Variable _output_field_resolved_to_none 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.
def __init__(self, *args, **kwargs): (source)
def add_related_update(self, model, field, value): (source)

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): (source)

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): (source)

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): (source)

Return a copy of the current Query. A lightweight alternative to deepcopy().

def get_related_updates(self): (source)

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): (source)

Undocumented

related_ids = (source)

Undocumented

related_updates: dict = (source)

Undocumented

Undocumented

def _setup_query(self): (source)

Run on initialization and at the end of chaining. Any attributes that would normally be set in __init__() should go here instead.