diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index a76598a9bf..f867571215 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -70,7 +70,7 @@ class ArrayField(CheckPostgresInstalledMixin, CheckFieldDefaultMixin, Field): ) ) else: - base_checks = self.base_field.check() + base_checks = self.base_field.check(**kwargs) if base_checks: error_messages = "\n ".join( "%s (%s)" % (base_check.msg, base_check.id) diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index f35211e8ed..d4289d79df 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -841,6 +841,25 @@ class TestChecks(PostgreSQLSimpleTestCase): self.assertEqual(errors[0].id, "postgres.E001") self.assertIn("max_length", errors[0].msg) + def test_base_field_check_kwargs(self): + passed_kwargs = None + + class MyField(models.Field): + def check(self, **kwargs): + nonlocal passed_kwargs + passed_kwargs = kwargs + return [] + + class MyModel(PostgreSQLModel): + field = ArrayField(MyField()) + + self.assertEqual(MyModel.check(databases=["default"]), []) + self.assertEqual( + passed_kwargs, + {"databases": ["default"]}, + "ArrayField.check kwargs should be passed to its base_field.", + ) + def test_invalid_base_fields(self): class MyModel(PostgreSQLModel): field = ArrayField(