Skip to content

Commit

Permalink
[IMP] models: when checking for data in a table, do not use column 'id'
Browse files Browse the repository at this point in the history
Replace the query "SELECT min(id) FROM xxx" by "SELECT 1 FROM xxx LIMIT 1".
Both requests are as efficient, and the second one does not crash if column
'id' is missing.
  • Loading branch information
rco-odoo committed Sep 25, 2014
1 parent 1f15055 commit 330a3ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openerp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2502,8 +2502,8 @@ def _auto_init(self, cr, context=None):
self._create_table(cr)
has_rows = False
else:
cr.execute('SELECT min(id) FROM "%s"' % (self._table,))
has_rows = cr.fetchone()[0] is not None
cr.execute('SELECT 1 FROM "%s" LIMIT 1' % self._table)
has_rows = cr.rowcount

cr.commit()
if self._parent_store:
Expand Down

0 comments on commit 330a3ff

Please sign in to comment.