odoo/upgrade-util#355

Created by Upgrade, Carsten Wolff (cawo)

Blocked

label
odoo-dev:master-imp_query_ids_server_side-cawo
head
4fde1e6cde469f7db0751c6984ec6f98910ea503
odoo/upgrade-util
master #355 missing r+

[IMP] pg,orm,models: query ids server side

[ADD] pg.query_ids: query large numbers of ids memory-safely

This is mainly the code that has been recently added to orm.recompute_fields, here we're making it re-usasble.

[IMP] orm.recompute_fields: use new pg.query_ids

This code in recompute_fields has been made re-usable in a new util pg.query_ids. Use that.

[FIX] models.remove_model: MemoryError

Traceback (most recent call last):
[...]
  File "/tmp/tmpipxrg2eq/migrations/util/models.py", line 563, in merge_model
    remove_model(cr, source, drop_table=drop_table, ignore_m2m=ignore_m2m)
  File "/tmp/tmpipxrg2eq/migrations/util/models.py", line 138, in remove_model
    it = chunks([id for (id,) in cr.fetchall()], chunk_size, fmt=tuple)
MemoryError

[IMP] pg.named_cursor: lessons learned from pg.query_ids

  • it is not exactly right to call into the Cursor's __enter__ and __exit__ methods
  • Cursor should be explicitly closed before it is garbage collected