Parcourir la source

Validate length of fieldname

version-14
Nabin Hait il y a 8 ans
Parent
révision
d070f880e2
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. +4
    -1
      frappe/model/db_schema.py

+ 4
- 1
frappe/model/db_schema.py Voir le fichier

@@ -102,6 +102,9 @@ class DbTable:
columns += self.columns.values()

for col in columns:
if len(col.fieldname) >= 64:
frappe.throw(_("Fieldname is limited to 64 characters"))
if col.fieldtype in type_map and type_map[col.fieldtype][0]=="varchar":

# validate length range
@@ -112,7 +115,7 @@ class DbTable:
try:
# check for truncation
max_length = frappe.db.sql("""select max(char_length(`{fieldname}`)) from `tab{doctype}`"""\
.format(fieldname=col.fieldname, doctype=self.doctype))
.format(fieldname=col.fieldname, doctype=self.doctype), debug=1)

except MySQLdb.OperationalError, e:
if e.args[0]==1054:


Chargement…
Annuler
Enregistrer