fix: improved implementation of between filter (#20190)

This commit is contained in:
Sagar Vora 2023-03-02 09:51:02 +05:30 committed by GitHub
parent f8dc121fbe
commit 70ede18942
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View file

@ -1070,13 +1070,7 @@ class Database:
if not datetime:
return FallBackDateTimeStr
if isinstance(datetime, str):
if ":" not in datetime:
datetime = datetime + " 00:00:00.000000"
else:
datetime = datetime.strftime("%Y-%m-%d %H:%M:%S.%f")
return datetime
return get_datetime(datetime).strftime("%Y-%m-%d %H:%M:%S.%f")
def get_creation_count(self, doctype, minutes):
"""Get count of records created in the last x minutes"""

View file

@ -762,6 +762,7 @@ class DatabaseQuery:
value = "('')"
else:
escape = True
df = meta.get("fields", {"fieldname": f.fieldname})
df = df[0] if df else None
@ -783,6 +784,7 @@ class DatabaseQuery:
or (df and (df.fieldtype == "Date" or df.fieldtype == "Datetime"))
):
escape = False
value = get_between_date_filter(f.value, df)
fallback = f"'{FallBackDateTimeStr}'"
@ -842,7 +844,7 @@ class DatabaseQuery:
value = f"{tname}.{quote}{f.value.name}{quote}"
# escape value
elif isinstance(value, str) and f.operator.lower() != "between":
elif escape and isinstance(value, str):
value = f"{frappe.db.escape(value, percent=False)}"
if (