浏览代码

Fixed #34370 -- Added integer fields validation as 64-bit on SQLite.

nabil-rady 2 年之前
父节点
当前提交
32d4b61c31
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 9 2
      django/db/backends/sqlite3/operations.py
  2. 3 0
      docs/releases/5.0.txt

+ 9 - 2
django/db/backends/sqlite3/operations.py

@@ -382,8 +382,15 @@ class DatabaseOperations(BaseDatabaseOperations):
         return "django_format_dtdelta(%s)" % ", ".join(fn_params)
 
     def integer_field_range(self, internal_type):
-        # SQLite doesn't enforce any integer constraints
-        return (None, None)
+        # SQLite doesn't enforce any integer constraints, but sqlite3 supports
+        # integers up to 64 bits.
+        if internal_type in [
+            "PositiveBigIntegerField",
+            "PositiveIntegerField",
+            "PositiveSmallIntegerField",
+        ]:
+            return (0, 9223372036854775807)
+        return (-9223372036854775808, 9223372036854775807)
 
     def subtract_temporals(self, internal_type, lhs, rhs):
         lhs_sql, lhs_params = lhs

+ 3 - 0
docs/releases/5.0.txt

@@ -279,6 +279,9 @@ Miscellaneous
 
 * The undocumented ``django.contrib.admin.helpers.checkbox`` is removed.
 
+* Integer fields are now validated as 64-bit integers on SQLite to match the
+  behavior of ``sqlite3``.
+
 .. _deprecated-features-5.0:
 
 Features deprecated in 5.0