OCA / openupgradelib

A library with support functions to be called from Odoo migration scripts.
GNU Affero General Public License v3.0
85 stars 171 forks source link

No operator matches the given name and argument types. #377

Closed stephansainleger closed 1 month ago

stephansainleger commented 1 month ago

Hello, I am trying to migrate an Odoo DB from 15.0 to 16.0 with OpenUpgrade, and I get this error :

2024-07-11 14:58:38,387 1 CRITICAL ou16 odoo.service.server: Failed to initialize database `ou16`. 
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/service/server.py", line 1310, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-16>", line 2, in new
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 484, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 236, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/opt/odoo/auto/addons/openupgrade_framework/odoo_patch/odoo/modules/migration.py", line 18, in migrate_module
    MigrationManager.migrate_module._original_method(self, pkg, stage)
  File "/opt/odoo/custom/src/odoo/odoo/modules/migration.py", line 189, in migrate_module
    migrate(self.cr, installed_version)
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2292, in wrapped_function
    func(
  File "/opt/odoo/auto/addons/openupgrade_scripts/scripts/digest/16.0.1.1/post-migration.py", line 21, in migrate
    openupgrade.delete_record_translations(env.cr, "digest", _translations_to_delete)
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2722, in delete_record_translations
    cr.execute(query, (record_id,))
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 321, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.UndefinedFunction: operator does not exist: character varying ? unknown
LINE 2: ...te_meta_title IS NOT NULL AND (website_meta_title ? 'en_US')...
                                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

I see it deals with the following line: https://github.com/OCA/openupgradelib/blob/58c40b5226d3d11cddec2633897074ac173f63f8/openupgradelib/openupgrade.py#L2716 added in commit https://github.com/OCA/openupgradelib/commit/6f652aa319d76a1699c9d661da0a7036269ae603

My postgres version is 12.15.

@MiquelRForgeFlow do you have any idea where the error can come from? Thanks for your help!

stephansainleger commented 1 month ago

By the way, I do not understand why the SQL command deals with column website_meta_title from model website.seo.metadata whereas it is not a field listed in the "translations to delete" https://github.com/OCA/OpenUpgrade/blob/16.0/openupgrade_scripts/scripts/digest/16.0.1.1/post-migration.py#L7 from the digest migration script.

stephansainleger commented 1 month ago

I have restarted my migration process from craft, and I do not reproduce the issue. I suspect an unfortunate manipulation from me when I resolved other migration issues... Sorry for the useless issue. I close it right now.