﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35147	Document that non-wrapped arithmetic with integer fields might require explicit output_field	Petar Netev	Petar Netev	"Hi team,

I faced an unexpected behaviour of the bitand method of the F model when used with a BigIntField value.
The change is that when I try to annotate and then filter on the promoted field, the query set is always empty, when it shouldn't be.

Code is as follows:

{{{
records_qs = Model.objects.annotate(flag_some_flag=F(""flags"").bitand(2**34)).filter(flag_some_flag=2**34)
}}}

The returned queryset is empty, but it shouldn't be.
Simple test with using only annotate and further filtration using python list comprehension from the queryset using the annotated field, returns the needed records.

The filtration works properly for flag values < {{{ 2**31 }}}.

I was looking for some notes in the Django 5 release notes, but I found nothing, and this is the version where the problem is faced. With Django 4.2.8 this problem is not faced.

Regards,
Petar Netev"	Cleanup/optimization	closed	Documentation	5.0	Normal	fixed	annotate, bitand, filter, integerfield, overflow	Petar Netev Simon Charette	Ready for checkin	1	0	0	0	0	0
