Browse Source

fix: change fieldtype of restrict_ip from data to small text (backport #18178) (#18183)

* fix: change fieldtype of restrict_ip from data to small text

(cherry picked from commit 359f0c3dcb)

* test: use middle_name instead of restrict_ip in test_index_and_unique_constraints

(cherry picked from commit 82d0faf3d2)

Co-authored-by: phot0n <ritwikpuri5678@gmail.com>
version-14
mergify[bot] 2 years ago
committed by GitHub
parent
commit
f16561114f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 30 deletions
  1. +3
    -3
      frappe/core/doctype/user/user.json
  2. +27
    -27
      frappe/tests/test_db_update.py

+ 3
- 3
frappe/core/doctype/user/user.json View File

@@ -126,7 +126,7 @@
{
"fieldname": "middle_name",
"fieldtype": "Data",
"label": "Middle Name (Optional)",
"label": "Middle Name",
"oldfieldname": "middle_name",
"oldfieldtype": "Data"
},
@@ -492,7 +492,7 @@
{
"description": "Restrict user from this IP address only. Multiple IP addresses can be added by separating with commas. Also accepts partial IP addresses like (111.111.111)",
"fieldname": "restrict_ip",
"fieldtype": "Data",
"fieldtype": "Small Text",
"label": "Restrict IP",
"permlevel": 1
},
@@ -722,7 +722,7 @@
"link_fieldname": "user"
}
],
"modified": "2022-05-25 01:00:51.345319",
"modified": "2022-09-19 16:05:46.485242",
"modified_by": "Administrator",
"module": "Core",
"name": "User",


+ 27
- 27
frappe/tests/test_db_update.py View File

@@ -40,46 +40,46 @@ class TestDBUpdate(FrappeTestCase):
frappe.reload_doctype("User", force=True)
frappe.model.meta.trim_tables("User")

make_property_setter(doctype, "restrict_ip", "unique", "1", "Int")
make_property_setter(doctype, "middle_name", "unique", "1", "Check")
frappe.db.updatedb(doctype)
restrict_ip_in_table = get_table_column("User", "restrict_ip")
self.assertTrue(restrict_ip_in_table.unique)
middle_name_in_table = get_table_column("User", "middle_name")
self.assertTrue(middle_name_in_table.unique)

make_property_setter(doctype, "restrict_ip", "unique", "0", "Int")
make_property_setter(doctype, "middle_name", "unique", "0", "Check")
frappe.db.updatedb(doctype)
restrict_ip_in_table = get_table_column("User", "restrict_ip")
self.assertFalse(restrict_ip_in_table.unique)
middle_name_in_table = get_table_column("User", "middle_name")
self.assertFalse(middle_name_in_table.unique)

make_property_setter(doctype, "restrict_ip", "search_index", "1", "Int")
make_property_setter(doctype, "middle_name", "search_index", "1", "Check")
frappe.db.updatedb(doctype)
restrict_ip_in_table = get_table_column("User", "restrict_ip")
self.assertTrue(restrict_ip_in_table.index)
middle_name_in_table = get_table_column("User", "middle_name")
self.assertTrue(middle_name_in_table.index)

make_property_setter(doctype, "restrict_ip", "search_index", "0", "Int")
make_property_setter(doctype, "middle_name", "search_index", "0", "Check")
frappe.db.updatedb(doctype)
restrict_ip_in_table = get_table_column("User", "restrict_ip")
self.assertFalse(restrict_ip_in_table.index)
middle_name_in_table = get_table_column("User", "middle_name")
self.assertFalse(middle_name_in_table.index)

make_property_setter(doctype, "restrict_ip", "search_index", "1", "Int")
make_property_setter(doctype, "restrict_ip", "unique", "1", "Int")
make_property_setter(doctype, "middle_name", "search_index", "1", "Check")
make_property_setter(doctype, "middle_name", "unique", "1", "Check")
frappe.db.updatedb(doctype)
restrict_ip_in_table = get_table_column("User", "restrict_ip")
self.assertTrue(restrict_ip_in_table.index)
self.assertTrue(restrict_ip_in_table.unique)
middle_name_in_table = get_table_column("User", "middle_name")
self.assertTrue(middle_name_in_table.index)
self.assertTrue(middle_name_in_table.unique)

make_property_setter(doctype, "restrict_ip", "search_index", "1", "Int")
make_property_setter(doctype, "restrict_ip", "unique", "0", "Int")
make_property_setter(doctype, "middle_name", "search_index", "1", "Check")
make_property_setter(doctype, "middle_name", "unique", "0", "Check")
frappe.db.updatedb(doctype)
restrict_ip_in_table = get_table_column("User", "restrict_ip")
self.assertTrue(restrict_ip_in_table.index)
self.assertFalse(restrict_ip_in_table.unique)
middle_name_in_table = get_table_column("User", "middle_name")
self.assertTrue(middle_name_in_table.index)
self.assertFalse(middle_name_in_table.unique)

make_property_setter(doctype, "restrict_ip", "search_index", "0", "Int")
make_property_setter(doctype, "restrict_ip", "unique", "1", "Int")
make_property_setter(doctype, "middle_name", "search_index", "0", "Check")
make_property_setter(doctype, "middle_name", "unique", "1", "Check")
frappe.db.updatedb(doctype)
restrict_ip_in_table = get_table_column("User", "restrict_ip")
self.assertFalse(restrict_ip_in_table.index)
self.assertTrue(restrict_ip_in_table.unique)
middle_name_in_table = get_table_column("User", "middle_name")
self.assertFalse(middle_name_in_table.index)
self.assertTrue(middle_name_in_table.unique)

# explicitly make a text index
frappe.db.add_index(doctype, ["email_signature(200)"])


Loading…
Cancel
Save