Adding a NOT NULL constraint to a model field named the same as an SQL keyword causes SQL Error
Bug #430728 reported by
Russell Briggs
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Fix Released
|
Undecided
|
Ujjvala Collins |
Bug Description
I have a model field named 'to' which is an SQL reserved word (I did not realise this at the time!)
There is bug in bin/osv/orm.py where it does not escape the field name properly when applying a NOT NULL constraint:
From line 1838 of bin/osv/orm.py (as of trunk revision 1887), in the _auto_init function:
query = 'UPDATE "%s" SET "%s"=%s WHERE %s is NULL' % (self._table, k, ss[0], k)
This should be changed to:
query = 'UPDATE "%s" SET "%s"=%s WHERE "%s" is NULL' % (self._table, k, ss[0], k)
(note the " " around the 4th %s)
Cheers!
Related branches
Changed in openobject-server: | |
assignee: | nobody → uco (Open ERP) (uco-openerp) |
Changed in openobject-server: | |
status: | New → Confirmed |
Changed in openobject-server: | |
status: | Confirmed → In Progress |
To post a comment you must log in.
Hello Russell,
Thank you for reporting.
Its fixed by revision 1866 <email address hidden>.
There is a limitation that you must not use this field in _order ,as it needs a heavy changes to be made.
Thank you.