Releases: beyond-the-cloud-dev/soql-lib
v2.1.0
28-July-2023
Changes
Ignore conditions when logic evaluates to true
Instead of doing this:
public SOQL.FilterGroup getFilters(String accountName, String accountIndustry) {
SOQL.FilterGroup group = SOQL.FilterGroup;
if (String.isNotBlank(accountName)) {
group.add(SOQL.Filter.name().equal(accountName));
}
if (String.isNotBlank(accountIndustry)) {
group.add(SOQL.Filter.with(Account.Industry).equal(accountIndustry));
}
return group;
}
Developer can do:
SOQL.FilterGroup
.add(SOQL.Filter.name().equal(accountName).ignoreWhen(String.isBlank(accountName)))
.add(SOQL.Filter.with(Account.Industry).equal(accountName).ignoreWhen(String.isBlank(accountIndustry)))
Check if record exists
Instead of:
Boolean isRecordExists = SOQL.of(Account.SObjectType).byId('someId').toList() > 0;
Developer can do:
Boolean isRecordExists = SOQL.of(Account.SObjectType).byId('someId').doExist();
Delete removeWhenNull method
Method .removeWhenNull()
is not longer supported and was deleted.
Developers can use .ignoreWhen(value == null)
instead.
v2.0.2
03-July-2023
Changes
Work with multi-select picklists
New methods were added:
includesAll
includesSome
excludesAll
excludesSome
Query Exception
Query Exception List has no rows for assignment to SObject
will be catch and null will be returned.
toValuesOf
Using https://salesforce.stackexchange.com/questions/393308/get-a-list-of-one-column-from-a-soql-result approach all values from one field can be gather.
v2.0.1
27-June-2023
Changes
Use Iterable Set
Based on Summer '23 the Set class now implements the Iterable interface.
Iterable was used as a supertype for List and Set.
custom LIKE
https://soql-lib.vercel.app/api/soql-filter#contains
You can specify custom contains with -
and %
.
SOQL.Filter.with(Account.Name).contains('_', 'My', '%')
of(String)
https://soql-lib.vercel.app/api/soql#of
You can create instance of SOQL dynamically.
SOQL of(String ofObject)
String ofObject = 'Account';
SOQL.of(ofObject).toList();
toField - null pointer check
https://soql-lib.vercel.app/api/soql#tofield
For null record .toField
method will return null value.
Code Refactoring
Unused lines of code were removed.
v2.0.0
05-June-2023
Changes
Code Against Interfaces, Not Implementations
Static variables return Interface instead of concrete class.
// Filter is interface
// QFilter is a class
public static Filter Filter {
get {
return new QFilter(binder);
}
}
String condition
String condition and FilterGroup/Filter are combined with AND.
SOQL.of(Account.SObjectType)
.whereAre('EmployeeNumber > 5')
.whereAre(SOQL.Filter.with(Account.Name).equal(accountName).removeWhenNull())
.toList();
Skip Binding for DataTime
System.QueryException: Invalid bind expression type of String for column of type Datetime
Data Literals are supported.
SOQL.of(Account.SObjectType)
.whereAre(SOQL.Filter.with(Account.CreatedDate).equal('YEASTERDAY'))
.toList();
Code Refactoring
Code is simpler, a lot of lines was removed.
v1.0.2
31-May-2023
Changes
with(field1 - field5)
Make code easier to read by new with
methods.
SOQL with(SObjectField field)
SOQL with(SObjectField field1, SObjectField field2);
SOQL with(SObjectField field1, SObjectField field2, SObjectField field3);
SOQL with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4);
SOQL with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4, SObjectField field5);
removeWhenNull
Condition will be removed when filter's value is null.
String accountName = null;
SOQL.of(Account.SObjectType)
.whereAre(SOQL.Filter.with(Account.Name).equal(accountName).removeWhenNull())
.toList();
anyConditionMatching
You can utilize the anyConditionMatching method, which joins conditions using the OR
operator.
SOQL.of(Account.SObjectType)
.whereAre(SOQL.FilterGroup
.add(SOQL.Filter.with(Account.Name).equal('My Account'))
.add(SOQL.Filter.with(Account.NumberOfEmployees).greaterThanOrEqual(10))
.anyConditionMatching()
).toList();
Fixed Issues
Count Fix
COUNT()
must be the only element in the SELECT list, any other fields will be automatically removed.
Code Refactoring
Code is simpler, a lot of lines was removed.
SOQL 1.0.1
- Dynamic orderBy -
orderBy(String field)
andorderBy(String field, String direction)
; - Documentation updates
- Empty
FilterGroup
fix
SOQL 1.0.0
First stable version.