fix: invlaid integer validations for biging
closes https://github.com/frappe/frappe/issues/25566
This commit is contained in:
parent
500992615f
commit
30f00fd5f3
3 changed files with 15 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ import frappe
|
|||
from frappe.cache_manager import clear_doctype_cache
|
||||
from frappe.core.doctype.doctype.doctype import (
|
||||
CannotIndexedError,
|
||||
DocType,
|
||||
DoctypeLinkError,
|
||||
HiddenAndMandatoryWithoutDefaultError,
|
||||
IllegalMandatoryError,
|
||||
|
|
@ -782,7 +783,7 @@ def new_doctype(
|
|||
custom: bool = True,
|
||||
default: str | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
) -> "DocType":
|
||||
if not name:
|
||||
# Test prefix is required to avoid coverage
|
||||
name = "Test " + "".join(random.sample(string.ascii_lowercase, 10))
|
||||
|
|
|
|||
|
|
@ -983,6 +983,9 @@ class BaseDocument:
|
|||
self.throw_length_exceeded_error(df, max_length, value)
|
||||
|
||||
elif column_type in ("int", "bigint", "smallint"):
|
||||
if cint(df.get("length")) > 11: # We implicitl switch to bigint for >11
|
||||
column_type = "bigint"
|
||||
|
||||
max_length = max_positive_value[column_type]
|
||||
|
||||
if abs(cint(value)) > max_length:
|
||||
|
|
|
|||
|
|
@ -99,6 +99,16 @@ class TestDBUpdate(FrappeTestCase):
|
|||
len(indexes), 1, msg=f"There should be 1 index on {doctype}.{field}, found {indexes}"
|
||||
)
|
||||
|
||||
def test_bigint_conversion(self):
|
||||
doctype = new_doctype(fields=[{"fieldname": "int_field", "fieldtype": "Int"}]).insert()
|
||||
|
||||
with self.assertRaises(frappe.CharacterLengthExceededError):
|
||||
frappe.get_doc(doctype=doctype.name, int_field=2**62 - 1).insert()
|
||||
|
||||
doctype.fields[0].length = 14
|
||||
doctype.save()
|
||||
frappe.get_doc(doctype=doctype.name, int_field=2**62 - 1).insert()
|
||||
|
||||
@run_only_if(db_type_is.MARIADB)
|
||||
def test_unique_index_on_install(self):
|
||||
"""Only one unique index should be added"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue