fix: auto add modified index when sort_field is set to it (#25686)

This is 2nd most common sort order, so we should support adding index
for it automatically.

Not quite sure on generalizing this behaviour *YET*
This commit is contained in:
Ankush Menat 2024-03-27 20:10:26 +05:30 committed by GitHub
parent 8dd10b3a03
commit 67bcda333e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -84,6 +84,12 @@ class MariaDBTable(DBTable):
for col in self.add_index
if not frappe.db.get_column_index(self.table_name, col.fieldname, unique=False)
]
if self.meta.sort_field == "modified" and frappe.db.get_column_index(
self.table_name, "modified", unique=False
):
add_index_query.append("ADD INDEX `modified`(`modified`)")
drop_index_query = []
for col in {*self.drop_index, *self.drop_unique}:

View file

@ -109,7 +109,7 @@ class SMTPServer:
frappe.request.after_response.add(self.quit)
elif frappe.job:
frappe.job.after_job.add(self.quit)
else:
elif not frappe.flags.in_test:
# Console?
import atexit