Skip to content

setDatabaseResult(List<Result>) does not save record ID #915

@TrangOul

Description

@TrangOul

Package Edition of Nebula Logger

Unlocked Package

Package Version of Nebula Logger

4.16.5

New Bug Summary

setDatabaseResult(Result) (a single Database Result) saves the record ID (if possible).
OTOH, setDatabaseResult(List) (a list of Results) does not.

The bulk method's behavior can be justified if multiple Results are passed, since the Log Entry stores only a single record ID.
But when a list with a single Result is passed, the record ID could be extracted and saved, like it is done in a non-bulkified method.

List<Account> accs = [
	SELECT Id, Name
	FROM Account
	WHERE IsPersonAccount = TRUE
	LIMIT 2
];

// expected INVALID_FIELD_FOR_INSERT_UPDATE because of the update with the Name field on Person Account
List<Database.SaveResult> multipleSrList = Database.update(accs, false);
Database.SaveResult singleSr = multipleSrList.get(0);
List<Database.SaveResult> singleSrList = new List<Database.SaveResult>{singleSr};
List<Database.SaveResult> noSrList = new List<Database.SaveResult>();

Logger.error('list size 2').setDatabaseResult(multipleSrList);
Logger.error('list size 1').setDatabaseResult(singleSrList);
Logger.error('list size 0').setDatabaseResult(noSrList);
Logger.error('single').setDatabaseResult(singleSr );

Logger.saveLog();
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions