MCPcopy
hub / github.com/django/django / test_add_binaryfield_mediumblob

Method test_add_binaryfield_mediumblob

tests/schema/tests.py:921–935  ·  view source on GitHub ↗

Test adding a custom-sized binary field on MySQL (#24846).

(self)

Source from the content-addressed store, hash-verified

919
920 @unittest.skipUnless(connection.vendor == "mysql", "MySQL specific")
921 def test_add_binaryfield_mediumblob(self):
922 """
923 Test adding a custom-sized binary field on MySQL (#24846).
924 """
925 # Create the table
926 with connection.schema_editor() as editor:
927 editor.create_model(Author)
928 # Add the new field with default
929 new_field = MediumBlobField(blank=True, default=b"123")
930 new_field.set_attributes_from_name("bits")
931 with connection.schema_editor() as editor:
932 editor.add_field(Author, new_field)
933 columns = self.column_classes(Author)
934 # Introspection treats BLOBs as TextFields
935 self.assertEqual(columns["bits"][0], "TextField")
936
937 @isolate_apps("schema")
938 @skipUnlessDBFeature("supports_json_field", "supports_stored_generated_columns")

Callers

nothing calls this directly

Calls 6

column_classesMethod · 0.95
MediumBlobFieldClass · 0.85
schema_editorMethod · 0.80
create_modelMethod · 0.45
add_fieldMethod · 0.45

Tested by

no test coverage detected