Skip to content

Commit

Permalink
Fix SQL injection lint in 18.0.1.0.0 pre-migrate.py
Browse files Browse the repository at this point in the history
  • Loading branch information
guewen committed Oct 21, 2024
1 parent 3693704 commit c0b4648
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions queue_job/migrations/18.0.1.0.0/pre-migrate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from openupgradelib import openupgrade

from odoo.tools import SQL


def migrate(cr, version):
if not version:
Expand All @@ -14,8 +16,14 @@ def migrate(cr, version):
for table, columns in table_column_map.items():
for column in columns:
if openupgrade.column_exists(cr, table, column):
cr.execute(f"""
UPDATE {table}
SET {column} = {column}::jsonb
WHERE {column} IS NOT NULL
""")
cr.execute(
SQL(
"""
UPDATE %(table)s
SET %(column)s = %(column)s::jsonb
WHERE %(column)s IS NOT NULL
""",
table=SQL.identifier(table),
column=SQL.identifier(column),
)
)

0 comments on commit c0b4648

Please sign in to comment.