Fixed #34936 -- Fixed migration crash for DecimalField with db_default on SQLite.

CAST() must be wrapped in parentheses to be recognized as an expression on SQLite.

Regression in 7414704e88.
This commit is contained in:
David Sanders 2023-10-30 20:44:44 +11:00 committed by Mariusz Felisiak
parent 1944f490f9
commit 797957fb48
4 changed files with 15 additions and 4 deletions

View file

@ -10,6 +10,7 @@ field.
"""
from datetime import datetime
from decimal import Decimal
from django.db import models
from django.db.models.functions import Coalesce, ExtractYear, Now, Pi
@ -33,6 +34,9 @@ class DBArticle(models.Model):
headline = models.CharField(max_length=100, db_default="Default headline")
pub_date = models.DateTimeField(db_default=Now())
cost = models.DecimalField(
max_digits=3, decimal_places=2, db_default=Decimal("3.33")
)
class Meta:
required_db_features = {"supports_expression_defaults"}