Reviewers: ced,

Message:
.

Description:
Question is: should it be just fixed like first patchset of this review
or for consistency reasons
updated to the migration code in account_invoice (despite probably not
needed)?

Please review this at http://codereview.tryton.org/210005/

Affected files:
  M trytond/ir/action.py


Index: trytond/ir/action.py
===================================================================

--- a/trytond/ir/action.py
+++ b/trytond/ir/action.py
@@ -356,14 +356,22 @@
         # report_content_custom to remove base64 encoding
         if (table.column_exist('report_content_data')
                 and table.column_exist('report_content_custom')):
-            cursor.execute('SELECT id, report_content_data '
+            limit = cursor.IN_MAX
+            cursor.execute('SELECT COUNT(id) '
                 'FROM "' + self._table + '"')
-            for report_id, content in cursor.fetchall():
-                if content:
-                    content = base64.decodestring(str(content))
-                    cursor.execute('UPDATE "' + self._table + '" '
-                        'SET report_content_custom = %s '
-                        'WHERE id = %s', (content, report_id))
+            report_count, = cursor.fetchone()
+            for offset in range(0, report_count, limit):
+                cursor.execute(cursor.limit_clause(
+                    'SELECT id, report_content_data '
+                    'FROM "' + self._table + '"'
+                    'ORDER BY id',
+                    limit, offset))
+                for report_id, report in cursor.fetchall():
+                    if report:
+                        report = buffer(base64.decodestring(str(report)))
+                        cursor.execute('UPDATE "' + self._table + '" '
+                            'SET report_content_custom = %s '
+                            'WHERE id = %s', (report, report_id))
             table.drop_column('report_content_data')

     def default_type(self):



--
[email protected] mailing list

Reply via email to