Skip to content

v2.2.1

Compare
Choose a tag to compare
@pgajek2 pgajek2 released this 08 Sep 06:57
· 35 commits to main since this release
b8e7d34

08-September-2023

Changes

New with method

Introducing the with method:

with(Iterable<String> fields)

Now you can pass a List or Set of fields for your query. This feature can be incredibly helpful for dynamic queries.

Note! Whenever possible, please use with(List<SObjectField> fields). SObjectField refers to the field in the code. If someone tries to remove it, an error message will appear: "This custom field definition is referenced elsewhere in salesforce.com."

Example usage with a List:

SOQL.of(Account.SObjectType)
    .with(new List<String>{'Id', 'Name', 'Industry'})
    .toList();

Example usage with a Set:

SOQL.of(Account.SObjectType)
    .with(new Set<String>{'Id', 'Name', 'Industry'})
    .toList();

Add COUNT to toInteger()

When the COUNT statement is not specified with toInteger(), COUNT will be automatically added. This simplifies the query.

Previously, code like the following would throw an error:

Integer accountsAmount = SOQL.of(Account.SObjectType).toInteger(); 

The valid option was:

// SELECT COUNT() FROM Account
Integer accountsAmount = SOQL.of(Account.SObjectType).count().toInteger();

Now, you can simply write:

// SELECT COUNT() FROM Account
Integer accountsAmount = SOQL.of(Account.SObjectType).toInteger();