Skip to content

Commit

Permalink
[IMP] convert_field_to_html: pre-clean empty values
Browse files Browse the repository at this point in the history
Avoid convertion of values which aren't set saving a handfull of useless
queries.
  • Loading branch information
chienandalu committed Jun 14, 2024
1 parent 5646c07 commit a05a740
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2467,6 +2467,14 @@ def convert_field_to_html(cr, table, field_name, html_field_name, verbose=True):
"You cannot use this method in an OpenUpgrade version prior to 7.0."
)
return
# Pre-clean empty values
cr.execute( # pylint: disable=E8103
"UPDATE %(table)s SET %(field)s = NULL WHERE %(field)s = ''"
% {
"field": field_name,
"table": table,
}
)
cr.execute( # pylint: disable=E8103
"SELECT id, %(field)s FROM %(table)s WHERE %(field)s IS NOT NULL"
% {
Expand Down

0 comments on commit a05a740

Please sign in to comment.