From 3af8d5caea0b667d7028e5cb23b6fd993778eb5a Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Fri, 17 Jun 2022 12:47:44 +0530 Subject: [PATCH] fix: Add fallbacks for values Psycopg seems to like None over () and MariaDB - PyMySQL can't seem to agree on anything - so this seems to keep everyone happy...a very delicate balance :crie: --- frappe/database/database.py | 5 +++-- frappe/database/postgres/database.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/database/database.py b/frappe/database/database.py index 68ab33d4f6..b6fc6f0fa8 100644 --- a/frappe/database/database.py +++ b/frappe/database/database.py @@ -71,7 +71,8 @@ class Database(object): self.password = password or frappe.conf.db_password self.value_cache = {} - # self.last_query lazy attribute of last sql query executed + # self.db_type: str + # self.last_query (lazy) attribute of last sql query executed @property def query(self): @@ -101,7 +102,7 @@ class Database(object): raise NotImplementedError def _transform_query(self, query: Query, values: QueryValues): - return query, values + return query, values or None def sql( self, diff --git a/frappe/database/postgres/database.py b/frappe/database/postgres/database.py index f5ecabd6c4..0d4a177741 100644 --- a/frappe/database/postgres/database.py +++ b/frappe/database/postgres/database.py @@ -193,6 +193,9 @@ class PostgresDatabase(PostgresExceptionUtil, Database): modify_query(query), modify_values(values), *args, **kwargs ) + def lazy_mogrify(self, *args, **kwargs) -> str: + return self.last_query + def get_tables(self, cached=True): return [ d[0]