mirror of
https://github.com/frappe/frappe.git
synced 2024-06-12 22:42:20 +00:00
fix(recorder): handle frappe.db.sql(run=0) (#25450)
This commit is contained in:
parent
dbe55d4ace
commit
df2b9c0983
|
@ -59,12 +59,17 @@ def record_sql(*args, **kwargs):
|
|||
result = frappe.db._sql(*args, **kwargs)
|
||||
end_time = time.monotonic()
|
||||
|
||||
query = getattr(frappe.db, "last_query", None)
|
||||
if not query or isinstance(result, str):
|
||||
# run=0, doesn't actually run the query so last_query won't be present
|
||||
return result
|
||||
|
||||
stack = []
|
||||
if frappe.local._recorder.config.capture_stack:
|
||||
stack = list(get_current_stack_frames())
|
||||
|
||||
data = {
|
||||
"query": str(frappe.db.last_query),
|
||||
"query": str(query),
|
||||
"stack": stack,
|
||||
"explain_result": [],
|
||||
"time": start_time,
|
||||
|
|
|
@ -83,6 +83,7 @@ class TestRecorder(FrappeTestCase):
|
|||
def test_explain(self):
|
||||
frappe.db.sql("SELECT * FROM tabDocType")
|
||||
frappe.db.sql("COMMIT")
|
||||
frappe.db.sql("select 1", run=0)
|
||||
self.stop_recording()
|
||||
|
||||
requests = frappe.recorder.get()
|
||||
|
|
Loading…
Reference in New Issue
Block a user