[FIX] sql_db: log-level debug_sql log parameters

Since 1a58e108 (on 10.0 and over) parameters are no longer present when
logging sql queries.

This removes some of the usefulness of the feature, and this commit adds
them back.

Since mogrify returns a byte string in the database encoding, we decode
it using the corresponding python encoding.

opw-1839241
closes #24446
This commit is contained in:
Nicolas Lempereur
2018-04-26 16:54:32 +02:00
parent b2ad88e38d
commit db86e1d9e4
+2 -1
View File
@@ -226,7 +226,8 @@ class Cursor(object):
if self.sql_log:
now = time.time()
_logger.debug("query: %s", query)
encoding = psycopg2.extensions.encodings[self.connection.encoding]
_logger.debug("query: %s", self._obj.mogrify(query, params).decode(encoding, 'replace'))
try:
params = params or None