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)
| 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 | """ |
no test coverage detected