forked from MirrorHub/synapse
Merge pull request #1939 from matrix-org/erikj/strip_sql_newlines
Strip newlines from SQL queries
This commit is contained in:
commit
bf92b7201f
1 changed files with 6 additions and 0 deletions
|
@ -80,7 +80,13 @@ class LoggingTransaction(object):
|
||||||
def executemany(self, sql, *args):
|
def executemany(self, sql, *args):
|
||||||
self._do_execute(self.txn.executemany, sql, *args)
|
self._do_execute(self.txn.executemany, sql, *args)
|
||||||
|
|
||||||
|
def _make_sql_one_line(self, sql):
|
||||||
|
"Strip newlines out of SQL so that the loggers in the DB are on one line"
|
||||||
|
return " ".join(l.strip() for l in sql.splitlines() if l.strip())
|
||||||
|
|
||||||
def _do_execute(self, func, sql, *args):
|
def _do_execute(self, func, sql, *args):
|
||||||
|
sql = self._make_sql_one_line(sql)
|
||||||
|
|
||||||
# TODO(paul): Maybe use 'info' and 'debug' for values?
|
# TODO(paul): Maybe use 'info' and 'debug' for values?
|
||||||
sql_logger.debug("[SQL] {%s} %s", self.name, sql)
|
sql_logger.debug("[SQL] {%s} %s", self.name, sql)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue