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

Strip newlines from SQL queries #1939

Merged
merged 1 commit into from
Feb 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions synapse/storage/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ def execute(self, sql, *args):
def executemany(self, 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):
sql = self._make_sql_one_line(sql)

# TODO(paul): Maybe use 'info' and 'debug' for values?
sql_logger.debug("[SQL] {%s} %s", self.name, sql)

Expand Down