MCPcopy
hub / github.com/django/django / add_update_values

Method add_update_values

django/db/models/sql/subqueries.py:81–104  ·  view source on GitHub ↗

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.

(self, values)

Source from the content-addressed store, hash-verified

79 self.get_compiler(using).execute_sql(NO_RESULTS)
80
81 def add_update_values(self, values):
82 """
83 Convert a dictionary of field name to value mappings into an update
84 query. This is the entry point for the public update() method on
85 querysets.
86 """
87 values_seq = []
88 for name, val in values.items():
89 field = self.get_meta().get_field(name)
90 model = field.model._meta.concrete_model
91 if field.name == "pk" and model._meta.is_composite_pk:
92 raise FieldError(
93 "Composite primary key fields must be updated individually."
94 )
95 if not field.concrete:
96 raise FieldError(
97 "Cannot update model field %r (only concrete fields are permitted)."
98 % field
99 )
100 if model is not self.get_meta().concrete_model:
101 self.add_related_update(model, field, val)
102 continue
103 values_seq.append((field, model, val))
104 return self.add_update_fields(values_seq)
105
106 def add_update_fields(self, values_seq):
107 """

Callers 2

update_batchMethod · 0.95
updateMethod · 0.80

Calls 7

add_related_updateMethod · 0.95
add_update_fieldsMethod · 0.95
FieldErrorClass · 0.90
itemsMethod · 0.45
get_fieldMethod · 0.45
get_metaMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected