From 9aa82af4bedab2e5889ea0d7a4f4f3fb0dadd0d9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 31 Aug 2015 09:47:06 +0200 Subject: [PATCH] [FIX] remove explicit naming of m2m indexes Postgres has a limit of 63 characters on identifiers, because of the way m2m index names are built the limit could relatively easily breached leading to a truncation of the index name, and in some cases collisions between the name of the two index. in CREATE INDEX is optional since Postgres 9.0, use this feature instead of generating index names, should avoid any possible collision on m2m index names. closes #7620 fixes #2780 (master) --- openerp/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/models.py b/openerp/models.py index 14692869c14..eddef09cd31 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -2767,8 +2767,8 @@ class BaseModel(object): if not cr.fetchall(): self._m2o_add_foreign_key_unchecked(m2m_tbl, col1, self, 'cascade') - cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (m2m_tbl, col1, m2m_tbl, col1)) - cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (m2m_tbl, col2, m2m_tbl, col2)) + cr.execute('CREATE INDEX ON "%s" ("%s")' % (m2m_tbl, col1)) + cr.execute('CREATE INDEX ON "%s" ("%s")' % (m2m_tbl, col2)) cr.execute("COMMENT ON TABLE \"%s\" IS 'RELATION BETWEEN %s AND %s'" % (m2m_tbl, self._table, ref)) cr.commit() _schema.debug("Create table '%s': m2m relation between '%s' and '%s'", m2m_tbl, self._table, ref)