Error with reduced search() using related search params

The reduced search function – search(false, true) – doesn’t return the correct results when searching on the same related search parameters. To explain, here is an example 1st search:

var pagesMainSub = databaseManager.getFoundSet(controller.getServerName(),"web_page")
pagesMainSub.find()
pagesMainSub.id_site = data.site.id
pagesMainSub.flag_publish = 1
pagesMainSub.web_page_to_attribute.attribute_key = "navMain"
var count = pagesMainSub.search()

Let’s say it returns 10 records. The following search will return one record as expected because id_page = 105 is in the 10 records returned above:

pagesMainSub.find()
pagesMainSub.id_page = 105
var count = pagesMainSub.search(false, true)

This search will also return the expected amount of records because there are records from the first search that match the related search parameter "web_page_to_attribute.attribute_value = “2”:

pagesMainSub.find()
pagesMainSub.web_page_to_attribute.attribute_value = "2"
var count = pagesMainSub.search(false, true)

However, if I were to instead follow up the first search with a reduced search using the same related search field (but with a different value), no records are returned even though web_page_to_attribute.attribute_key = “navMainSub” is in the 10 records returned from the first search:

pagesMainSub.find()
pagesMainSub.web_page_to_attribute.attribute_key = "xxx"
var count = pagesMainSub.search(false, true)

Outer join or left outer join on the relation “web_page_to_attribute” doesn’t make a difference.

David,

Reduce search means combine the existing search condition of the foundset with the new condition as AND:
foundset.condition = foundset.condition AND new_condition

If your new_condition does not match any records, the AND-result will also return no records.

Hope this helps,

Rob