Skip to content

v6.0.0

Choose a tag to compare

@pgajek2 pgajek2 released this 24 Aug 11:58
· 46 commits to main since this release
0b220aa

v6.0.0 - August 24, 2025

Scope

  • NEW: SOQL Evaluator for Static SOQL Processing
  • Enhanced SOQLCache with Relationship Field Support
  • Comprehensive Documentation Overhaul
  • Multiple Condition Support for Cached Queries
  • Improved Testing and Code Coverage

SOQLEvaluator

  • NEW: Introduced SOQLEvaluator for processing static query results
  • NEW: Complete mocking framework for static data evaluation
  • NEW: Field-level security support for static data
  • NEW: All standard SOQL Lib result methods (toId, toList, toMap, etc.)

SOQLCache

  • NEW: Added relationship field support with with(relationshipName, field) methods
  • NEW: Added toIdOf() method for extracting IDs from specific fields
  • NEW: Enhanced filtering flexibility with allowFilteringByNonUniqueFields() and allowQueryWithoutConditions()
  • NEW: Support for multiple conditions and additional allowed condition fields
  • IMPROVED: Better error handling and query validation

Major New Features

SOQL Evaluator - Static Data Processing

The biggest addition to v6.0.0 is the new SOQLEvaluator class, which brings SOQL Lib's powerful API to static query results. This enables you to apply the same transformation and filtering patterns to in-memory data that you use for database queries.

Basic Usage

List<Account> processedAccounts = SOQLEvaluator.of([SELECT Id, Name FROM Account])
    .stripInaccessible()
    .toList();

// Extract data using familiar methods
Set<Id> ownerIds = SOQLEvaluator.of([SELECT OwnerId FROM Account])
    .toIdsOf(Account.OwnerId);

Map<Id, Account> accountMap = SOQLEvaluator.of([SELECT Id, Name FROM Account])
    .toMap();

Field-Level Security Support

List<Task> safeTasks = SOQLEvaluator.of([SELECT Id, Type FROM Task])
    .stripInaccessible(AccessType.READABLE)
    .toList();

Comprehensive Mocking for Tests

// In your controller
public static List<Account> getAccounts() {
    return SOQLEvaluator.of([SELECT Id, Name FROM Account])
        .mockId('ExampleController.getAccounts')
        .toList();
}

// In your test
@IsTest
static void testProcessExternalAccounts() {
    List<Account> mockAccounts = new List<Account>{
        new Account(Name = 'Test Account 1'),
        new Account(Name = 'Test Account 2')
    };
    
    SOQLEvaluator.mock('ExampleController.getAccounts')
        .thenReturn(mockAccounts);
    
    Test.startTest();
    List<Account> result = ExampleController.getAccounts();
    Test.stopTest();
    
    Assert.areEqual(2, result.size());
}

Enhanced SOQLCache with Relationship Field Support

SOQLCache now supports querying relationship fields directly, making it easier to work with related data in cached queries.

New Relationship Field Methods

// Single relationship field
SOQLCache.of(Account.SObjectType)
    .with(Account.Name)
    .with('Owner', User.Name)
    .byId(accountId)
    .toObject();

// Multiple relationship fields
SOQLCache.of(Account.SObjectType)
    .with('Owner', User.Name, User.Email, User.Department)
    .byId(accountId)
    .toObject();

// Using field collections
SOQLCache.of(Account.SObjectType)
    .with('Owner', new List<SObjectField>{ User.Name, User.Email })
    .byId(accountId)
    .toObject();

New toIdOf() Method for SOQLCache

// Extract specific field IDs from cached data
Id ownerId = SOQLCache.of(Account.SObjectType)
    .byId(accountId)
    .toIdOf(Account.OwnerId);

Enhanced Cache Configuration

Flexible Filtering Options

// Allow filtering by non-unique fields (use with caution)
SOQLCache.of(Account.SObjectType)
    .allowFilteringByNonUniqueFields()
    .whereEqual(Account.Industry, 'Technology')
    .toList();

// Allow queries without WHERE conditions
SOQLCache.of(Account.SObjectType)
    .allowQueryWithoutConditions()
    .toList();

Additional Allowed Condition Fields

public class SOQL_Account extends SOQLCache implements SOQLCache.Selector {
    public override List<SObjectField> additionalAllowedConditionFields() {
        return new List<SObjectField>{ 
            Account.Industry, 
            Account.Type 
        };
    }
}

Documentation Revolution

We've completely overhauled our documentation to provide the best developer experience possible:

Comprehensive Code Examples

  • Titled Code Blocks: Every code example now has descriptive titles for better context
  • Real-World Scenarios: Added extensive examples covering complex business cases
  • Side-by-Side Comparisons: Traditional SOQL vs SOQL Lib approaches clearly demonstrated

Breaking Changes

Encapsulation improvements

Class: SOQL.cls

.of methods will now return the SOQL.Queryable interface instead of the SOQL class itself.
If this is a breaking change for you, retain the previous approach.

Previous:

public static SOQL of(SObjectType ofObject) {
   return new SOQL(ofObject);
}

public static SOQL of(String ofObject) {
   return new SOQL(ofObject);
}

New:

public static Queryable of(SObjectType ofObject) {
   return new SOQL(ofObject);
}

public static Queryable of(String ofObject) {
   return new SOQL(ofObject);
}

Download: v6.0.0 Release

Documentation: https://soql.beyondthecloud.dev

GitHub: https://github.com/beyond-the-cloud-dev/soql-lib