#34936 closed Bug (fixed)
db_default with decimal.Decimal() crashes on SQLite.
Reported by: | Mariusz Felisiak | Owned by: | David Sanders |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Release blocker | Keywords: | |
Cc: | Lily Foote | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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 , 13 months ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 13 months ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 13 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