Database.convertLead() DML count
As stated on Execution Governors and Limits:
Calls to the following methods count against the number of DML queries issued in a request.
Approval.process
Database.convertLead
Database.emptyRecycleBin
Database.rollback
Database.setSavePoint
delete
andDatabase.delete
insert
andDatabase.insert
merge
andDatabase.merge
undelete
andDatabase.undelete
update
andDatabase.update
upsert
andDatabase.upsert
System.runAs
Every time you call any of them, the system increments the DML counter by 1, regardless of how many records were processed by the statement.
I can't verify this is what happens with Database.convertLead
, but you can insert up to 10 different types of SObject
in one List<SObject>
even without using that method, as astutely noted by @Joca in the comments.
insert new List<SObject>
{
new Account(...),
new Contact(...),
new Opportunity(...)
};
system.assertEquals(1, Limits.getDmlStatements());
The reason is that 1 DML statement can insert multiple records. The system created an Account, an Opportunity and a Contact, all with a single Apex DML statement: Database.convertLead(lc);
The number of records created is irrelevant to the number of statements used.