Open DaRealWorm opened 2 years ago
Seems fairly logical the fix. I dunno if this has any play in the relationship between this bug and theirs https://github.com/salesagility/SuiteCRM/issues/9147
Unfortunately, their bug #9147 does not resolve Contacts issue. Contacts with deleted email addresses are still found via API V8 queries. Has anyone found a solution to this problem?
This issue has been mentioned on SuiteCRM. There might be relevant details there:
https://community.suitecrm.com/t/api-returning-duplicate-records-on-email1-filter/88399/8
Exactly! THX!
Would someone like to make a PR to fix this issue, from the fixed SQL provided in this reply to the forum post?: https://community.suitecrm.com/t/api-returning-duplicate-records-on-email1-filter/88399/4
Issue
When making an API call to the V8 Json API for contacts filtering by
email1
field eg[...]/V8/module/Contacts?filter[email1][eq]=test@example.com
contacts are returned that do no currently have this address but had it in the past and is now deleted. The resulting query isSELECT contacts.id FROM email_addresses JOIN email_addr_bean_rel ON email_addresses.id = email_addr_bean_rel.email_address_id JOIN contacts ON contacts.id = email_addr_bean_rel.bean_id where ((email_addresses.email_address = 'test@example.com') AND contacts.deleted = '0') AND contacts .deleted=0 LIMIT 0,20
. This will return all contacts that currently have or ever had a relationship to this e-mail address. Only deleted contacts are excluded but no deletedemail_addr_bean_rel
s.Expected Behavior
Only contacts currently having an active (
deleted = 0
) relationship to the e-mail address should be returned.Actual Behavior
Contacts whose relationship to this address has been deleted will still be found and returned.
Possible Fix
Including
and email_addr_bean_rel.deleted = 0
in the query. Can be included inApi/V8/Service/ModuleService.php
where the Email where clause is being constructed.Steps to Reproduce
[...]/V8/module/Contacts?filter[email1][eq]=test@example.com
Context
I was trying to find a contact by e-mail address and got one that obviously did not contain the searched address. After checking the query I found that the contact previously had the address but was removed later.
Your Environment