Closed chienandalu closed 8 months ago
hello, here I do:
1.- make import:
https://github.com/OCA/openupgradelib/blob/35f51c4301a691d78e9e84cdc3651ff385ccdb92/openupgradelib/openupgrade_160.py#L11
from psycopg2 import sql, extras
2.- delete from https://github.com/OCA/openupgradelib/blob/35f51c4301a691d78e9e84cdc3651ff385ccdb92/openupgradelib/openupgrade_160.py#L396 to https://github.com/OCA/openupgradelib/blob/35f51c4301a691d78e9e84cdc3651ff385ccdb92/openupgradelib/openupgrade_160.py#L399
3.- then adding to your code: https://github.com/OCA/openupgradelib/blob/35f51c4301a691d78e9e84cdc3651ff385ccdb92/openupgradelib/openupgrade_160.py#L409
`
for id_, old_content in cr.fetchall():
new_content = {}
if column_type == "jsonb":
for lang, lang_old_content in old_content.items():
lang_new_content = convert_string_bootstrap_4to5(lang_old_content)
new_content[lang] = lang_new_content
new_content = extras.Json(new_content)
old_content = extras.Json(old_content)
else:
new_content = convert_string_bootstrap_4to5(old_content)
if old_content != new_content:
cr.execute(
sql.SQL("UPDATE {table} SET {field} = %s WHERE id = %s").format(
**format_query_args
),
(
new_content,
id_,
),
)
`
@chienandalu I ran into the same problem and propose to just have psycopg2 sort it out: #357
Closed in favor of #357
ref: https://github.com/OCA/OpenUpgrade/issues/4263
Options for the fix:
_convert_field_bootstrap_4to5_sql
cc @Tecnativa TT46660