[FIX] res.partner: current name_search() implementation tends to skip a few valid...
authorOlivier Dony <odo@openerp.com>
Thu, 5 Sep 2013 17:02:51 +0000 (19:02 +0200)
committerOlivier Dony <odo@openerp.com>
Thu, 5 Sep 2013 17:02:51 +0000 (19:02 +0200)
commit95b7d5bcaf82bf3332c5e118a4ed8ba5a297b215
treeaf276e544f6ac712bbef0127b253156186fdcf54
parentbb67905bc52bd1db100004d38d26690a6afc6daa
[FIX] res.partner: current name_search() implementation tends to skip a few valid results during early autocompletion - mitigation attempt

The main reason for the semi-random behavior
observed during auto-completion is the
missing ORDER BY clause in the pre-filtering
SQL query.

The ORDER BY clause is expensive but inevitable
if we want to apply a correct LIMIT, otherwise
we would return random `limit` results among
all the possible matches.

The current SQL query seems convoluted due
to the duplicated CASE clause but it
performs slightly better than the equivalent
CTE-based (WITH...) query, so it was preferred.

There is still a chance of returning too
few results due to double limit application,
as further discussed in bug 1203727

lp bug: https://launchpad.net/bugs/1203727 fixed

bzr revid: odo@openerp.com-20130905170251-x47w1zrm43d0k9wb
openerp/addons/base/res/res_partner.py