diff --git a/frappe/__version__.py b/frappe/__version__.py index 327d0f84fb..4e6731b58a 100644 --- a/frappe/__version__.py +++ b/frappe/__version__.py @@ -1,2 +1,2 @@ from __future__ import unicode_literals -__version__ = "6.23.2" +__version__ = "6.23.3" diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index e874aadc6f..1eacbd64a4 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -237,8 +237,9 @@ class DocType(Document): # a DocType's name should not start with a number or underscore # and should only contain letters, numbers and underscore - if not re.match("^(?![\W])[^\d_][\w]+$", name, re.UNICODE): - frappe.throw(_("DocType's name should start with a letter and it can only consist of letters, numbers and underscores")) + is_a_valid_name = re.match("^(?![\W])[^\d_\s][\w ]+$", name, re.UNICODE) + if not is_a_valid_name: + frappe.throw(_("DocType's name should start with a letter and it can only consist of letters, numbers, spaces and underscores"), frappe.NameError) def validate_fields_for_doctype(doctype): validate_fields(frappe.get_meta(doctype, cached=False)) diff --git a/frappe/core/doctype/doctype/test_doctype.py b/frappe/core/doctype/doctype/test_doctype.py index 2419f0c7d1..c06bde9690 100644 --- a/frappe/core/doctype/doctype/test_doctype.py +++ b/frappe/core/doctype/doctype/test_doctype.py @@ -9,4 +9,23 @@ import unittest # test_records = frappe.get_test_records('DocType') class TestDocType(unittest.TestCase): - pass + def new_doctype(self, name): + return frappe.get_doc({ + "doctype": "DocType", + "module": "Core", + "custom": 1, + "fields": [{"label": "Some Field", "fieldname": "some_fieldname", "fieldtype": "Data"}], + "permissions": [{"role": "System Manager", "read": 1}], + "name": name + }) + + def test_validate_name(self): + self.assertRaises(frappe.NameError, self.new_doctype("_Some DocType").insert) + self.assertRaises(frappe.NameError, self.new_doctype("8Some DocType").insert) + self.assertRaises(frappe.NameError, self.new_doctype("Some (DocType)").insert) + for name in ("Some DocType", "Some_DocType"): + if frappe.db.exists("DocType", name): + frappe.delete_doc("DocType", name) + + doc = self.new_doctype(name).insert() + doc.delete() diff --git a/frappe/hooks.py b/frappe/hooks.py index 73615ee1af..5203f1a5bb 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -5,7 +5,7 @@ app_publisher = "Frappe Technologies Pvt. Ltd." app_description = "Full stack web framework with Python, Javascript, MariaDB, Redis, Node" app_icon = "octicon octicon-circuit-board" -app_version = "6.23.2" +app_version = "6.23.3" app_color = "orange" source_link = "https://github.com/frappe/frappe" app_license = "MIT" diff --git a/frappe/utils/error.py b/frappe/utils/error.py index d271bd208a..4994e13317 100644 --- a/frappe/utils/error.py +++ b/frappe/utils/error.py @@ -185,8 +185,8 @@ def collect_error_snapshots(): def clear_old_snapshots(): """Clear snapshots that are older than a month""" - frappe.delete_doc("Error Snapshot", frappe.db.sql_list("""select name from `tabError Snapshot` - where creation < date_sub(now(), interval 1 month) order by creation desc""")) + frappe.db.sql("""delete from `tabError Snapshot` + where creation < date_sub(now(), interval 1 month)""") path = get_error_snapshot_path() today = datetime.datetime.now() diff --git a/frappe/utils/fixtures.py b/frappe/utils/fixtures.py index c3fb932c13..2c56d953d6 100644 --- a/frappe/utils/fixtures.py +++ b/frappe/utils/fixtures.py @@ -14,7 +14,8 @@ def sync_fixtures(app=None): apps = frappe.get_installed_apps() for app in apps: if os.path.exists(frappe.get_app_path(app, "fixtures")): - for fname in os.listdir(frappe.get_app_path(app, "fixtures")): + fixture_files = sorted(os.listdir(frappe.get_app_path(app, "fixtures"))) + for fname in fixture_files: if fname.endswith(".json") or fname.endswith(".csv"): import_doc(frappe.get_app_path(app, "fixtures", fname), ignore_links=True, overwrite=True) diff --git a/setup.py b/setup.py index 841aaea605..69dddcb5c8 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages from pip.req import parse_requirements -version = "6.23.2" +version = "6.23.3" requirements = parse_requirements("requirements.txt", session="") setup(