[6.1, 7.0, trunk] Cannot create manual many2many fields on models with long table names

Bug #1174078 reported by Stefan Rijnhart (Opener)
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

On manually created many2many fields, the cross table is composed as follows:

    'x_' + target_model + '_' + source_model + '_' + field_name + '_rel'

Due to the relation length limit of 63 in Postgresql, you will run into trouble when both model names are a bit long. Although the table is created in that case with a truncated name, creating the indexes fails because these are created as

    cross_table + '_' + column_name + '_index'

Because the relation name length limit applies equally to the index, the truncated index name is equal to the truncated cross table name which raises an exception like

  File "/home/oerttrtst61/bzr/openobject-server/openerp/osv/orm.py", line 3174, in _m2m_raise_or_create_relation
    cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (m2m_tbl, col1, m2m_tbl, col1))
  File "/home/oerttrtst61/bzr/openobject-server/openerp/sql_db.py", line 152, in wrapper
    return f(self, *args, **kwargs)
  File "/home/oerttrtst61/bzr/openobject-server/openerp/sql_db.py", line 212, in execute
    res = self._obj.execute(query, params)
ProgrammingError: relation "x_magerp_product_attribute_options_product_template_x_magerp_br" already exists

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.