Unverified Commit 1bf72997 authored by John Davis's avatar John Davis Committed by Nicola Soranzo
Browse files

Handle "%" character in raw SQL

This statement is prepared for SQLAlchemy but executed via psycopg2 in
the `pgcleanup.py` script. For psycopg2, the "%" character should be replaced
with %% (see docs
https://www.psycopg.org/docs/usage.html#passing-parameters-to-sql-queries).
SQLAlchemy already takes care of it automatically.
parent b10c9576
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -401,7 +401,8 @@ class RequiresDiskUsageRecalculation:
            statements = calculate_user_disk_usage_statements(user_id, quota_source_map)

            for sql, args in statements:
                sql, _ = re.subn(r"\:([\w]+)", r"%(\1)s", sql)
                sql = sql.replace("%", "%%")
                sql = re.sub(r"\:([\w]+)", r"%(\1)s", sql)
                new_args = {}
                for key, val in args.items():
                    if isinstance(val, list):