refactor: clean up code to py39+ supported syntax - f-strings instead of format - latest typing support instead of pre 3.9 TitleCase - remove UTF-8 declarations. - many more changes Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
20 lines
468 B
Python
20 lines
468 B
Python
import frappe
|
|
|
|
|
|
def execute():
|
|
duplicateRecords = frappe.db.sql(
|
|
"""select count(name) as `count`, allow, user, for_value
|
|
from `tabUser Permission`
|
|
group by allow, user, for_value
|
|
having count(*) > 1 """,
|
|
as_dict=1,
|
|
)
|
|
|
|
for record in duplicateRecords:
|
|
frappe.db.sql(
|
|
"""delete from `tabUser Permission`
|
|
where allow=%s and user=%s and for_value=%s limit {}""".format(
|
|
record.count - 1
|
|
),
|
|
(record.allow, record.user, record.for_value),
|
|
)
|