#36722 assigned Bug

MySQL backend raises error when selecting 0 using an expression targeting an autofield.

Reported by: Clifford Gama Owned by: Clifford Gama
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: allows_auto_pk_0
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In MySQL, Django currently raises a ValueError when trying to insert 0 into an AutoField, which is correct when saving because MySQL interprets 0 as auto-increment unless NO_AUTO_VALUE_ON_ZERO is set.

However, the backend also raises an error when using expressions like Value(0, BigAutoField()) in select filters, which I believe is a bug.

Discovered in these logs.

Change History (0)

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