Refs #31055 -- Adjusted passing of Field.check kwargs to ArrayField.base_field.

This was missed when Field.check(databases) was introduced.
This commit is contained in:
Simon Charette 2025-11-08 16:40:26 -05:00 committed by Mariusz Felisiak
parent 1b539ef27e
commit 96ee097bd6
2 changed files with 20 additions and 1 deletions

View file

@ -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(