﻿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
34370	IntegerField validators don't work if the database is SQLite, leading to overflow errors	Alex Urbanowicz	Mohamed Nabil Rady	"The [https://docs.djangoproject.com/en/4.1/ref/models/fields/#integerfield documentation for IntegerField] states that:

''It uses MinValueValidator and MaxValueValidator to validate the input based on the values that the default database supports.''

The [https://docs.djangoproject.com/en/4.1/ref/models/fields/#positiveintegerfield PositiveIntegerField] states that:

""Like an IntegerField, but must be either positive or zero (0). Values from 0 to 2147483647 are safe in all databases supported by Django. The value 0 is accepted for backward compatibility reasons.""

So it is simple to assume that PositiveIntergerField uses MaxValueValidator that applies the limit of the default database.

Yet it is possible, while using SQLite to attempt to store the value of positive integer not supported by the DB, which leads to OverflowError:

**Python int too large to convert to SQLite INTEGER**

So it is either the IntegerField's MaxValueValidator is not applied, contrary to what the documentation suggests, or the documentation has an error for lack of specifying that you must use an explicit validator to validate to the safe value given (why not default then?).

In my opinion it should be limited to the safe value by default, or have the MaxValueValidator check it by default against the database limit.

Should I prepare the patch to limit it to the safe value?

This is also related to #27397."	Cleanup/optimization	closed	Database layer (models, ORM)	4.1	Normal	fixed	IntegerField SQLite MaxValueValidator	Simon Charette Sarah Boyce	Ready for checkin	1	0	0	0	0	0
