summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2015-08-31 09:47:06 +0200
committerXavier Morel <xmo@odoo.com>2015-08-31 09:47:06 +0200
commit9aa82af4bedab2e5889ea0d7a4f4f3fb0dadd0d9 (patch)
treee24d010157840ea2a5937677b68c8fd876e45333
parent291cb7e3dd505ebee972933fbcdcb9b78da9a0da (diff)
[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. <name> 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)
-rw-r--r--openerp/models.py4
1 files 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)