Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit bf92b72

Browse files
authored
Merge pull request #1939 from matrix-org/erikj/strip_sql_newlines
Strip newlines from SQL queries
2 parents b2d20e9 + 1a4f802 commit bf92b72

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

synapse/storage/_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ def execute(self, sql, *args):
8080
def executemany(self, sql, *args):
8181
self._do_execute(self.txn.executemany, sql, *args)
8282

83+
def _make_sql_one_line(self, sql):
84+
"Strip newlines out of SQL so that the loggers in the DB are on one line"
85+
return " ".join(l.strip() for l in sql.splitlines() if l.strip())
86+
8387
def _do_execute(self, func, sql, *args):
88+
sql = self._make_sql_one_line(sql)
89+
8490
# TODO(paul): Maybe use 'info' and 'debug' for values?
8591
sql_logger.debug("[SQL] {%s} %s", self.name, sql)
8692

0 commit comments

Comments
 (0)