Skip to content

Commit

Permalink
[FIX] registry: check if index exists before logging
Browse files Browse the repository at this point in the history
The `update_db_index` method is called even if the field has no index
(the check on `index` field attribute is here on purpose).

Before 13f02a6 was applied, the call of `sql.drop_index` was taking
care of the index existence if a `IF EXISTS` SQL statement, so even if
the field had no index it wasn't causing any issue.

With 13f02a6 applied, the log 'Keep unexpected index' is spam even if
the field has actually no index at all in the database.

This commit ensures to check the existence of the index before logging.

closes #75387

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
  • Loading branch information
sebalix authored and gurneyalex committed Aug 30, 2021
1 parent 69be08d commit 57f078b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion odoo/fields.py
Expand Up @@ -1002,7 +1002,7 @@ def update_db_index(self, model, column):
sql.create_index(model._cr, indexname, model._table, ['"%s"' % self.name])
except psycopg2.OperationalError:
_schema.error("Unable to add index for %s", self)
else:
elif sql.index_exists(model._cr, indexname):
_schema.info("Keep unexpected index %s on table %s", indexname, model._table)

def update_db_related(self, model):
Expand Down

0 comments on commit 57f078b

Please sign in to comment.