Opened 10 hours ago

Last modified 10 hours ago

#35815 new Bug

System check for default database values with expressions prohibits non-expressions

Reported by: Tim Graham Owned by:
Component: Core (System checks) Version: 5.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Since its introduction in Django 5.0, the fields.E011 system check for database backends that have DatabaseFeatures.supports_expression_defaults = False requires literal defaults to be wrapped in Value.

There are a number of test models that have int, float and string db_defaults that will raise a system check error if DatabaseFeatures.supports_expression_defaults = False
since these models don't have required_db_features = {"supports_expression_defaults"}.

I'm working on MongoDB which doesn't support any database defaults, literal or expressions.

Change History (1)

comment:1 by Tim Graham, 10 hours ago

I'm not sure if the appropriate solution is to add Value wrapping to all literal defaults in Django's test models or to modify the isinstance(db_default, Value) check to also accept int/float, str, etc.

Note: See TracTickets for help on using tickets.
Back to Top