Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Issue with a big set of Ids in a where clause #87

@derroman

Description

@derroman

Hi @jongpie and @jamessimone

Similar to the issue mentioned over here: jamessimone/apex-dml-mocking#2 (which has been fixed by @jamessimone ) I discover the same issue also in this framework (which is pretty cool by the way)

So, in my scenario I do a query on account team member by providing a huge list of account ids

I've created a small Repository which has a single method:

public with sharing class AccountTeamMemberRepository extends SObjectRepository {

    public override SObjectType getSObjectType() {
        return Schema.AccountTeamMember.SObjectType;
    }
    
    public List<AccountTeamMember> getAccountTeamMembersByAccountIds(Set<Id> accountIds) {
        return new SObjectQueryBuilder(this.getSObjectType())
                .addAllFields()
                .filterBy(new QueryFilter().filterByField(new QueryField(Schema.AccountTeamMember.AccountId), QueryOperator.IS_IN, accountIds))
                .getQueryResults();
    }
}

When I run this in Anonymous Apex with a set of more than 12 account Ids, I get an error

//anonymous apex
AccountTeamMemberRepository repo = new AccountTeamMemberRepository();
repo.getAccountTeamMembersByAccountIds(new Set<Id>{
        '0010O0000265ZliQAE', '0010O000028mXFFQA2', '0010O000028peYlQAI', '0010O000028pexAQAQ', '0010O00002B6sgBQAR', '0010O00002B78G6QAJ', '0010O00002B7AceQAF', '0010O00002B7AgWQAV', '0010O00002B7FilQAF', '0010O00002ENWYuQAP', '0010O00002ENXJDQA5', '0010O00002Md4QBQAZ', '0010O00002MdnnFQAR', '0010O00002OVySHQA1'    
});
Error on line 126, column 1: System.QueryException: invalid ID field: ...
Class.QueryBuilder.executeQuery: line 126, column 1
Class.QueryBuilder.doGetQueryResults: line 97, column 1
Class.SObjectQueryBuilder.getQueryResults: line 210, column 1

When I debug the query right before execution we can clearly see, that the last "entry" is just some dots, and most of the Ids are missing

SELECT account.name, accountaccesslevel, accountid, automaticallyadded__c, caseaccesslevel, contactaccesslevel, createdby.name, createdbyid, createddate, id, isdeleted, lastmodifiedby.name, lastmodifiedbyid, lastmodifieddate, opportunityaccesslevel, photourl, projectaccesslevel__c, systemmodstamp, teammemberrole, title, user.name, userid
FROM AccountTeamMember
WHERE AccountId IN ('0010O0000265ZliQAE', '0010O000028mXFFQA2', '0010O000028peYlQAI', '0010O000028pexAQAQ', '0010O00002B6sgBQAR', '0010O00002B78G6QAJ', '0010O00002B7AceQAF', '0010O00002B7AgWQAV', '0010O00002B7FilQAF', '0010O00002ENWYuQAP', '...')

mhh... ?! :-(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions