MCPcopy
hub / github.com/django/django / reduce

Method reduce

django/db/migrations/operations/models.py:151–379  ·  view source on GitHub ↗
(self, operation, app_label)

Source from the content-addressed store, hash-verified

149 return False
150
151 def reduce(self, operation, app_label):
152 if (
153 isinstance(operation, DeleteModel)
154 and self.name_lower == operation.name_lower
155 and not self.options.get("proxy", False)
156 ):
157 return []
158 elif (
159 isinstance(operation, RenameModel)
160 and self.name_lower == operation.old_name_lower
161 ):
162 return [replace(self, name=operation.new_name)]
163 elif (
164 isinstance(operation, AlterModelOptions)
165 and self.name_lower == operation.name_lower
166 ):
167 options = {**self.options, **operation.options}
168 for key in operation.ALTER_OPTION_KEYS:
169 if key not in operation.options:
170 options.pop(key, None)
171 return [replace(self, options=options)]
172 elif (
173 isinstance(operation, AlterModelManagers)
174 and self.name_lower == operation.name_lower
175 ):
176 return [replace(self, managers=operation.managers)]
177 elif (
178 isinstance(operation, AlterModelTable)
179 and self.name_lower == operation.name_lower
180 ):
181 return [
182 replace(
183 self,
184 options={**self.options, "db_table": operation.table},
185 ),
186 ]
187 elif (
188 isinstance(operation, AlterModelTableComment)
189 and self.name_lower == operation.name_lower
190 ):
191 return [
192 replace(
193 self,
194 options={
195 **self.options,
196 "db_table_comment": operation.table_comment,
197 },
198 ),
199 ]
200 elif (
201 isinstance(operation, AlterTogetherOptionOperation)
202 and self.name_lower == operation.name_lower
203 ):
204 return [
205 replace(
206 self,
207 options={
208 **self.options,

Callers

nothing calls this directly

Calls 5

replaceFunction · 0.90
getMethod · 0.45
popMethod · 0.45
copyMethod · 0.45
reduceMethod · 0.45

Tested by

no test coverage detected