The below code can be executed in Anonymous window. I have seen this code working before.
I am expecting qProdList to return exact number of records that i pass in the set "st".I am passing 18 items in st. But the number of product records returned by qProdList is always 10 records.
I have verified all these 18 items in the database, and all are present. only post I am applying string operation it results in 10 items.
Please advice what could be the reason string operation is behaving inconsistent in apex?
set<string> st = new set<String>{'A,'B','C','D','E','F','G,'S,'Q','N','M','Y','O','P,'J,'K,'I','H'};
system.debug('st : ' + st.size() + '--' + st);
string b = string.valueof(st).split('[{}]')[1];
system.debug('b : ' + b);
string qProd = 'select isActive,ProductCode from Product2 where isActive = true and ProductCode IN (\''+ b.replaceAll('\\, ','\',\'')+'\')';
system.debug('qProd : + ' + qProd);
list<Product2> qProdList = Database.query(qProd);
system.debug(' -- qProdList -- : ' + qProdList.size());
IN
operator with a bound set object, or construct a dynamic query by doingString.join()
on the set.