[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:
parent
1f15055de3
commit
330a3ff6ea
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue