If I attempt to search by Account Name, Accounts who are associated with a parent account will not be found based on the way the SQL is generated:
Here is the SQL 5.0.0d generates for a Account Name Search; this returns 0 results (although it should return a hit)
SELECT accounts.id ,
accounts_cstm.*,
accounts.name ,
jt0.name parent_name ,
jt0.assigned_user_id parent_name_owner ,
'Accounts' parent_name_mod,
accounts.parent_id ,
accounts.shipping_address_street ,
accounts.assigned_user_id
FROM accounts
LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c
LEFT JOIN accounts jt0 ON jt0.id= accounts.parent_id
AND jt0.deleted=0
AND jt0.deleted=0
where ((jt0.name like '%ennis%'))
AND accounts.deleted=0
ORDER BY accounts.name ASC LIMIT 0,21
If I make the following change the query I get the expected results:
SELECT accounts.id ,
accounts_cstm.*,
accounts.name ,
jt0.name parent_name ,
jt0.assigned_user_id parent_name_owner ,
'Accounts' parent_name_mod,
accounts.parent_id ,
accounts.shipping_address_street ,
accounts.assigned_user_id
FROM accounts
LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c
LEFT JOIN accounts jt0 ON jt0.id= accounts.parent_id
AND jt0.deleted=0
AND jt0.deleted=0
where ((accounts.name like '%ennis%'))
AND accounts.deleted=0
ORDER BY accounts.name ASC LIMIT 0,21
So the remaining question is, why is sugar attempting to match on the Parent record name instead of the child record name? This architecture means that any child account names will never show up in searches, only parent records will show up in searches..


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks