projects
/
odoo
/
odoo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1f15055
)
[IMP] models: when checking for data in a table, do not use column 'id'
author
Raphael Collet
<rco@openerp.com>
Wed, 24 Sep 2014 13:41:09 +0000
(15:41 +0200)
committer
Raphael Collet
<rco@openerp.com>
Thu, 25 Sep 2014 08:37:28 +0000
(10:37 +0200)
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.
openerp/models.py
patch
|
blob
|
history
diff --git
a/openerp/models.py
b/openerp/models.py
index
360c220
..
4f9fc28
100644
(file)
--- a/
openerp/models.py
+++ b/
openerp/models.py
@@
-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: