Merge pull request #33491 from sokumon/row-size-issue
fix: prevent row-size limit error
This commit is contained in:
commit
2c3b85a7e0
2 changed files with 15 additions and 0 deletions
|
|
@ -443,6 +443,9 @@ def get_definition(fieldtype, precision=None, length=None, *, options=None):
|
|||
|
||||
if length:
|
||||
if coltype == "varchar":
|
||||
# Reference: https://mariadb.com/docs/server/server-usage/storage-engines/innodb/innodb-row-formats/troubleshooting-row-size-too-large-errors-with-innodb
|
||||
if length < 64:
|
||||
length = 64
|
||||
size = length
|
||||
elif coltype == "int" and length < 11:
|
||||
# allow setting custom length for int if length provided is less than 11
|
||||
|
|
|
|||
|
|
@ -176,6 +176,18 @@ class TestDBUpdate(IntegrationTestCase):
|
|||
|
||||
self.assertEqual(frappe.db.get_column_type(referring_doctype.name, link), "uuid")
|
||||
|
||||
@run_only_if(db_type_is.MARIADB)
|
||||
def test_varchar_length(self):
|
||||
from frappe.database.schema import add_column
|
||||
|
||||
test_doc = new_doctype().insert()
|
||||
col_name = f"col_{frappe.generate_hash(length=4)}"
|
||||
add_column(test_doc.name, fieldtype="Data", column_name=col_name, length=50)
|
||||
length = frappe.db.sql(
|
||||
f"SELECT CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'tab{test_doc.name}' AND COLUMN_NAME = '{col_name}' ",
|
||||
)[0][0]
|
||||
self.assertEqual(length, 64)
|
||||
|
||||
|
||||
class TestDBUpdateSanityChecks(IntegrationTestCase):
|
||||
@run_only_if(db_type_is.MARIADB)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue