#36722: MySQL backend raises error when selecting 0 using an expression
targeting
an autofield.
-------------------------------------+-------------------------------------
Reporter: Clifford | Owner: Clifford Gama
Gama |
Type: Bug | Status: assigned
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords: allows_auto_pk_0
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In MySQL, Django currently raises a `ValueError` when trying to insert 0
into an `AutoField`, which is correct when saving because MySQL
[https://dev.mysql.com/doc/refman/8.4/en/sql-
mode.html#sqlmode_no_auto_value_on_zero 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 [https://djangoci.com/job/pull-requests-
noble/database=mysql,label=noble-
pr,python=python3.12/1000/testReport/junit/aggregation.tests/AggregateAnnotationPruningTests/test_aggregate_reference_lookup_rhs_iter/
these logs].
--
Ticket URL: <https://code.djangoproject.com/ticket/36722>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019a6d83abe0-2e69f1eb-5f24-4904-910e-97c049a4fe7d-000000%40eu-central-1.amazonses.com.