fix(db): Log queried tables through generated query
This commit is contained in:
parent
b4578dc632
commit
5a29177e6b
1 changed files with 4 additions and 6 deletions
|
|
@ -189,9 +189,6 @@ class Database(object):
|
|||
|
||||
self._cursor.execute(query, values)
|
||||
|
||||
if frappe.flags.in_migrate:
|
||||
self.log_touched_tables(query, values)
|
||||
|
||||
if debug:
|
||||
time_end = time()
|
||||
frappe.errprint(("Execution time: {0} sec").format(round(time_end - time_start, 2)))
|
||||
|
|
@ -263,6 +260,9 @@ class Database(object):
|
|||
mogrified_query = mogrified_query or self.mogrify(query, values)
|
||||
frappe.log(f"<<<< query\n{mogrified_query}\n>>>>")
|
||||
|
||||
if frappe.flags.in_migrate:
|
||||
self.log_touched_tables(mogrified_query or query)
|
||||
|
||||
def mogrify(self, query, values):
|
||||
"""build the query string with values"""
|
||||
if not values:
|
||||
|
|
@ -1217,9 +1217,7 @@ class Database(object):
|
|||
else:
|
||||
return None
|
||||
|
||||
def log_touched_tables(self, query, values=None):
|
||||
if values:
|
||||
query = frappe.safe_decode(self._cursor.mogrify(query, values))
|
||||
def log_touched_tables(self, query):
|
||||
if is_query_type(query, ("insert", "delete", "update", "alter", "drop", "rename")):
|
||||
# single_word_regex is designed to match following patterns
|
||||
# `tabXxx`, tabXxx and "tabXxx"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue