[IMP] models: when checking for data in a table, do not use column 'id'

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.
This commit is contained in:
Raphael Collet 2014-09-24 15:41:09 +02:00
parent 1f15055de3
commit 330a3ff6ea
1 changed files with 2 additions and 2 deletions

View File

@ -2502,8 +2502,8 @@ class BaseModel(object):
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: