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

Commit

Permalink
Merge pull request #1939 from matrix-org/erikj/strip_sql_newlines
Browse files Browse the repository at this point in the history
Strip newlines from SQL queries
  • Loading branch information
erikjohnston authored Feb 23, 2017
2 parents b2d20e9 + 1a4f802 commit bf92b72
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit bf92b72

Please sign in to comment.