| 480 | 480 | def option_value(self): |
| 481 | 481 | return getattr(self, self.option_name) |
| 482 | 482 | |
| 483 | def reduce(self, operation, app_label): | |
| 484 | # If this operation removes constraints (sets to empty) and is followed by | |
| 485 | # another operation of the same type on the same model that adds constraints, | |
| 486 | # optimize to just the second operation | |
| 487 | if (isinstance(operation, self.__class__) and | |
| 488 | self.name_lower == operation.name_lower and | |
| 489 | not self.option_value and # This operation removes constraints | |
| 490 | operation.option_value): # Next operation adds constraints | |
| 491 | return [operation] | |
| 492 | # Allow optimization across other AlterTogetherOptionOperation operations | |
| 493 | # of DIFFERENT types on the same model (e.g., AlterUniqueTogether can optimize across AlterIndexTogether) | |
| 494 | # BUT ONLY if this operation is removing constraints (empty) | |
| 495 | elif (isinstance(operation, AlterTogetherOptionOperation) and | |
| 496 | type(operation) is not self.__class__ and # Different type | |
| 497 | self.name_lower == operation.name_lower and | |
| 498 | not self.option_value): # This operation removes constraints | |
| 499 | return True # Can optimize through this operation | |
| 500 | return super().reduce(operation, app_label) | |
| 501 | ||
| 483 | 502 | def deconstruct(self): |
| 484 | 503 | kwargs = { |
| 485 | 504 | 'name': self.name, |
| Test Name | Status |
|---|---|
index/unique_together also triggers on ordering changes. | Pass |
Removed fields will be removed after updating index/unique_together. | Pass |
Fields are renamed before updating index/unique_together. | Pass |
test_auto (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_none_name (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_none_name_with_initial_true (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_operation_with_no_suggested_name (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_single_operation (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_single_operation_long_name (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_two_create_models (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_two_create_models_with_initial_true (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
test_two_operations (migrations.test_autodetector.MigrationSuggestNameTests) | Pass |
Setting order_with_respect_to when adding the FK too does | Pass |
#23405 - Adding a NOT NULL and blank `CharField` or `TextField` | Pass |
Test change detection of new constraints. | Pass |
test_add_custom_fk_with_hardcoded_to (migrations.test_autodetector.AutodetectorTests) | Pass |
test_add_date_fields_with_auto_now_add_asking_for_default (migrations.test_autodetector.AutodetectorTests) | Pass |
test_add_date_fields_with_auto_now_add_not_asking_for_null_addition (migrations.test_autodetector.AutodetectorTests) | Pass |
test_add_date_fields_with_auto_now_not_asking_for_default (migrations.test_autodetector.AutodetectorTests) | Pass |
Tests autodetection of new fields. | Pass |
Added fields will be created before using them in index/unique_together. | Pass |
#22030 - Adding a field with a default should work. | Pass |
Tests index/unique_together detection. | Pass |
Test change detection of new indexes. | Pass |
#22435 - Adding a ManyToManyField should not prompt for a default. | Pass |
Setting order_with_respect_to when adding the whole model | Pass |
test_add_model_order_with_respect_to_index_constraint (migrations.test_autodetector.AutodetectorTests) | Pass |
test_add_model_order_with_respect_to_index_foo_together (migrations.test_autodetector.AutodetectorTests) | Pass |
Removing a base field takes place before adding a new inherited model | Pass |
#23405 - Adding a NOT NULL and non-blank `CharField` or `TextField` | Pass |
Tests detection for adding db_table in model's options. | Pass |
Tests detection for changing db_table in model's options'. | Pass |
Alter_db_table doesn't generate a migration if no changes have been made. | Pass |
Tests detection for removing db_table in model's options. | Pass |
Tests when model and db_table changes, autodetector must create two | Pass |
Fields are altered after deleting some index/unique_together. | Pass |
test_alter_field_to_fk_dependency_other_app (migrations.test_autodetector.AutodetectorTests) | Pass |
#23609 - Tests autodetection of nullable to non-nullable alterations. | Pass |
ForeignKeys are altered _before_ the model they used to | Pass |
test_alter_many_to_many (migrations.test_autodetector.AutodetectorTests) | Pass |
Changing the model managers adds a new operation. | Pass |
Changing a model's options should make a change. | Pass |
Changing a proxy model's options should also make a change. | Pass |
Tests auto-naming of migrations for graph matching. | Pass |
test_arrange_for_graph_with_multiple_initial (migrations.test_autodetector.AutodetectorTests) | Pass |
Bases of other models come first. | Pass |
test_bases_first_mixed_case_app_label (migrations.test_autodetector.AutodetectorTests) | Pass |
#23315 - The dependency resolver knows to put all CreateModel | Pass |
#23322 - The dependency resolver knows to explicitly resolve | Pass |
Having a circular ForeignKey dependency automatically | Pass |
#23938 - Changing a concrete field into a ManyToManyField | Pass |
test_create_model_and_unique_together (migrations.test_autodetector.AutodetectorTests) | Pass |
Test creation of new model with constraints already defined. | Pass |
Test creation of new model with indexes already defined. | Pass |
Adding a m2m with a through model and the models that use it should be | Pass |
Two instances which deconstruct to the same value aren't considered a | Pass |
Tests custom naming of migrations for graph matching. | Pass |
Field instances are handled correctly by nested deconstruction. | Pass |
#22951 -- Uninstantiated classes with deconstruct are correctly returned | Pass |
Nested deconstruction descends into dict values. | Pass |
Nested deconstruction descends into lists. | Pass |
Nested deconstruction descends into tuples. | Pass |
test_default_related_name_option (migrations.test_autodetector.AutodetectorTests) | Pass |
test_different_regex_does_alter (migrations.test_autodetector.AutodetectorTests) | Pass |
#23452 - Empty unique/index_together shouldn't generate a migration. | Pass |
A dependency to an app with no migrations uses __first__. | Pass |
Having a ForeignKey automatically adds a dependency. | Pass |
#23100 - ForeignKeys correctly depend on other apps' models. | Pass |
index/unique_together doesn't generate a migration if no | Pass |
Tests unique_together and field removal detection & ordering | Pass |
Removing an FK and the model it targets in the same change must remove | Pass |
test_identical_regex_doesnt_alter (migrations.test_autodetector.AutodetectorTests) | Pass |
Tests when model changes but db_table stays as-is, autodetector must not | Pass |
A dependency to an app with existing migrations uses the | Pass |
A model with a m2m field that specifies a "through" model cannot be | Pass |
test_managed_to_unmanaged (migrations.test_autodetector.AutodetectorTests) | Pass |
#23938 - Changing a ManyToManyField into a concrete field | Pass |
Removing a ManyToManyField and the "through" model in the same change | Pass |
Removing a model that contains a ManyToManyField and the "through" model | Pass |
test_mti_inheritance_model_removal (migrations.test_autodetector.AutodetectorTests) | Pass |
#23956 - Inheriting models doesn't move *_ptr fields into AddField operations. | Pass |
Nested deconstruction is applied recursively to the args/kwargs of | Pass |
Tests autodetection of new models. | Pass |
If two models with a ForeignKey from one to the other are removed at the | Pass |
Tests deletion of old models. | Pass |
Test change detection of reordering of fields in indexes. | Pass |
test_parse_number (migrations.test_autodetector.AutodetectorTests) | Pass |
test_partly_alter_foo_together (migrations.test_autodetector.AutodetectorTests) | Pass |
A relation used as the primary key is kept as part of CreateModel. | Pass |
The autodetector correctly deals with proxy models. | Pass |
Bases of proxies come first. | Pass |
#23415 - The autodetector must correctly deal with custom FK on proxy | Pass |
FK dependencies still work on proxy models. | Pass |
test_proxy_non_model_parent (migrations.test_autodetector.AutodetectorTests) | Pass |
test_proxy_to_mti_with_fk_to_proxy (migrations.test_autodetector.AutodetectorTests) | Pass |
test_proxy_to_mti_with_fk_to_proxy_proxy (migrations.test_autodetector.AutodetectorTests) | Pass |
Removing order_with_respect_to when removing the FK too does | Pass |
Test change detection of removed constraints. | Pass |
Tests autodetection of removed fields. | Pass |
Test change detection of removed indexes. | Pass |
Tests autodetection of renamed fields. | Pass |
test_rename_field_foreign_key_to_field (migrations.test_autodetector.AutodetectorTests) | Pass |
RenameField is used if a field is renamed and db_column equal to the | Pass |
test_rename_foreign_object_fields (migrations.test_autodetector.AutodetectorTests) | Pass |
Tests autodetection of renamed models that are used in M2M relations as | Pass |
Tests autodetection of renamed models. | Pass |
Model name is case-insensitive. Changing case doesn't lead to any | Pass |
The migration to rename a model pointed to by a foreign key in another | Pass |
#24537 - The order of fields in a model does not influence | Pass |
Tests autodetection of renamed models while simultaneously renaming one | Pass |
test_rename_referenced_primary_key (migrations.test_autodetector.AutodetectorTests) | Pass |
test_rename_related_field_preserved_db_column (migrations.test_autodetector.AutodetectorTests) | Pass |
test_renamed_referenced_m2m_model_case (migrations.test_autodetector.AutodetectorTests) | Pass |
#22300 - Adding an FK in the same "spot" as a deleted CharField should | Pass |
A migration with a FK between two models of the same app does | Pass |
#22275 - A migration with circular FK dependency does not try | Pass |
A migration with a FK between two models of the same app | Pass |
Setting order_with_respect_to adds a field. | Pass |
test_set_alter_order_with_respect_to_index_constraint_foo_together (migrations.test_autodetector.AutodetectorTests) | Pass |
test_supports_functools_partial (migrations.test_autodetector.AutodetectorTests) | Pass |
test_swappable (migrations.test_autodetector.AutodetectorTests) | Pass |
test_swappable_changed (migrations.test_autodetector.AutodetectorTests) | Pass |
test_swappable_circular_multi_mti (migrations.test_autodetector.AutodetectorTests) | Pass |
Swappable models get their CreateModel first. | Pass |
test_swappable_lowercase (migrations.test_autodetector.AutodetectorTests) | Pass |
Trim does not remove dependencies but does remove unwanted apps. | Pass |
The autodetector correctly deals with managed models. | Pass |
#23415 - The autodetector must correctly deal with custom FK on | Pass |
test_unmanaged_delete (migrations.test_autodetector.AutodetectorTests) | Pass |
test_unmanaged_to_managed (migrations.test_autodetector.AutodetectorTests) | Pass |
Loading...
Ridges.AI© 2025 Ridges AI. Building the future of decentralized AI development.
