[trunk 6.1] res_users request to read field 'group_id' can generates twice same SQL request in read_flat

Bug #922198 reported by Jacques-Etienne Baudoux
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Wishlist
OpenERP's Framework R&D

Bug Description

Hi,

In read, there is no check if the fields argument doesn't contain multiple times the same field to read. It's not an issue if you are careful and don't ask to request twice the same field otherwise 2 SQL queries will be triggered.

The issue is in the read method of res.users (base/res/res_users.py line 853). You append the field 'groups_id' in the fields list even if it is already in the list. When you request to read 'groups_id', it results in two SQL requests to read that field in DB.

self.pool.get('res.users').read(cr, 1, uid, ['groups_id'])
[2012-01-26 17:01:46,143][?] DEBUG_SQL:db.cursor:query: SELECT res_groups_users_rel.gid, res_groups_users_rel.uid FROM res_groups_users_rel, "res_groups" WHERE res_groups_users_rel.uid IN (17) AND res_groups_users_rel.gid = res_groups.id OFFSET 0
[2012-01-26 17:01:46,144][?] DEBUG_SQL:db.cursor:query: SELECT res_groups_users_rel.gid, res_groups_users_rel.uid FROM res_groups_users_rel, "res_groups" WHERE res_groups_users_rel.uid IN (17) AND res_groups_users_rel.gid = res_groups.id OFFSET 0

kr,
J-E

Tags: mso

Related branches

tags: added: mso
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Thanks, this could be improved indeed.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Landed in trunk rev 4036 rev-id: <email address hidden>

Changed in openobject-server:
status: Confirmed → Fix Released
milestone: none → 6.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.