From 5f89da0837009debda998af30f280d7075fb1a4d Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 12 Dec 2023 05:39:11 +0100 Subject: [5.0.x] Fixed #35018 -- Fixed migrations crash on GeneratedField with BooleanField as output_field on Oracle < 23c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks Václav Řehák for the report. Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95. Backport of fcf95e592774a6ededec35481a2061474d467a2b from main. --- tests/lookup/tests.py | 1 - tests/schema/tests.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py index 8af459ccd7..a198a13b62 100644 --- a/tests/lookup/tests.py +++ b/tests/lookup/tests.py @@ -1522,7 +1522,6 @@ class LookupQueryingTests(TestCase): qs = Season.objects.order_by(LessThan(F("year"), 1910), F("year")) self.assertSequenceEqual(qs, [self.s1, self.s3, self.s2]) - @skipUnlessDBFeature("supports_boolean_expr_in_select_clause") def test_aggregate_combined_lookup(self): expression = Cast(GreaterThan(F("year"), 1900), models.IntegerField()) qs = Season.objects.aggregate(modern=models.Sum(expression)) diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 046097366c..36c6b5e4bf 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -852,6 +852,27 @@ class SchemaTests(TransactionTestCase): False, ) + @isolate_apps("schema") + @skipUnlessDBFeature("supports_virtual_generated_columns") + def test_add_generated_boolean_field(self): + class GeneratedBooleanFieldModel(Model): + value = IntegerField(null=True) + has_value = GeneratedField( + expression=Q(value__isnull=False), + output_field=BooleanField(), + db_persist=False, + ) + + class Meta: + app_label = "schema" + + with connection.schema_editor() as editor: + editor.create_model(GeneratedBooleanFieldModel) + obj = GeneratedBooleanFieldModel.objects.create() + self.assertIs(obj.has_value, False) + obj = GeneratedBooleanFieldModel.objects.create(value=1) + self.assertIs(obj.has_value, True) + @isolate_apps("schema") @skipUnlessDBFeature("supports_stored_generated_columns") def test_add_generated_field(self): -- cgit v1.3