mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[5.0.x] 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 in7414704e88. Backport of797957fb48from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
b735b90f43
commit
8dde0504f3
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user