Ticket #13614: 0001_sanitize_mysql_queries.patch

File 0001_sanitize_mysql_queries.patch, 778 bytes (added by rcrdnalor, 12 months ago)

Patch to fix Python Bindings for MySQLDB calls of executemany

  • mythtv/bindings/python/MythTV/_conn_mysqldb.py

    diff --git a/mythtv/bindings/python/MythTV/_conn_mysqldb.py b/mythtv/bindings/python/MythTV/_conn_mysqldb.py
    index 177a880a12..3f79819821 100644
    a b class LoggedCursor( MySQLdb.cursors.Cursor ): 
    4141    def _ping121(self): self._get_db().ping()
    4242    def _ping122(self): self._get_db().ping(True)
    4343
    44     def _sanitize(self, query): return query.replace('?', '%s')
     44    def _sanitize(self, query):
     45        if isinstance(query, bytearray):
     46            # MySQLdb calls execute() as bytearrays, already sanitized
     47            return query
     48        return query.replace('?', '%s')
    4549
    4650    def log_query(self, query, args):
    4751        if isinstance(query, bytearray):