#34936 closed Bug (fixed)
db_default with decimal.Decimal() crashes on SQLite.
Description ¶
db_default
with decimal.Decimal()
crashes on SQLite. For example, adding the following field
models.DecimalField(null=True, max_digits=5, decimal_places=2, db_default=Decimal("3.33")
generates:
ALTER TABLE "test_adfldd_pony" ADD COLUMN "height" decimal DEFAULT CAST('3.33' AS NUMERIC) NULL;
and crashes with:
django.db.utils.OperationalError: near "(": syntax error
Change History (7)
comment:1 by , 16 months ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 16 months ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 16 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Confirmed that SQLite doesn't like
CAST(…)
in theDEFAULT
clause unless wrapped in parens 👍https://www.sqlite.org/lang_createtable.html#the_default_clause