Skip to content

Commit

Permalink
Validate fieldnames that contain space (#5499)
Browse files Browse the repository at this point in the history
  • Loading branch information
netchampfaris authored and nabinhait committed Apr 30, 2018
1 parent c6e4699 commit 8923cb6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions frappe/model/db_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,10 @@ def drop_table(self,table_name):
self.db.sql("DROP TABLE IF EXISTS %s "%(table_name))

def validate_column_name(n):
n = n.replace(' ','_').strip().lower()
special_characters = re.findall("[\W]", n, re.UNICODE)
if special_characters:
special_characters = ", ".join('"{0}"'.format(c) for c in special_characters)
frappe.throw(_("Fieldname {0} cannot have special characters like {1}").format(cstr(n), special_characters), InvalidColumnName)
frappe.throw(_("Fieldname {0} cannot have special characters like {1}").format(frappe.bold(cstr(n)), special_characters), InvalidColumnName)
return n

def validate_column_length(fieldname):
Expand Down

0 comments on commit 8923cb6

Please sign in to comment.