diff options
| author | Simon Charette <charette.s@gmail.com> | 2023-11-07 21:47:37 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-11-08 15:48:15 +0300 |
| commit | 8b1acc0440418ac8f45ba48e2dfcf5126c83341b (patch) | |
| tree | 40e63236a346a455807ae07f84e965f5321aed0a /tests/schema | |
| parent | 5f2f12f61c8e9bc0323efea391ee56e721ce14c6 (diff) | |
Refs #30446, Refs #34944 -- Fixed crash when adding GeneratedField with string Value().
This should allow smarter output_field inferring in functions dealing
with text expressions.
Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.
Diffstat (limited to 'tests/schema')
| -rw-r--r-- | tests/schema/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 72f90c934b..1298b32caf 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -844,6 +844,23 @@ class SchemaTests(TransactionTestCase): @isolate_apps("schema") @skipUnlessDBFeature("supports_stored_generated_columns") + def test_add_generated_field_with_string_value(self): + class GeneratedFieldStringValueModel(Model): + value = GeneratedField(expression=Value("static string"), db_persist=True) + + class Meta: + app_label = "schema" + + with CaptureQueriesContext(connection) as ctx: + with connection.schema_editor() as editor: + editor.create_model(GeneratedFieldStringValueModel) + self.assertIs( + any("None" in query["sql"] for query in ctx.captured_queries), + False, + ) + + @isolate_apps("schema") + @skipUnlessDBFeature("supports_stored_generated_columns") def test_add_generated_field_with_output_field(self): class GeneratedFieldOutputFieldModel(Model): price = DecimalField(max_digits=7, decimal_places=2) |
