beyond-the-cloud-dev / soql-lib

The SOQL Lib provides functional constructs for SOQL queries in Apex.
https://soql.beyondthecloud.dev/
MIT License
61 stars 9 forks source link

.toValuesOf returning empty set when one of extracted values is null #90

Closed szczursonn closed 10 months ago

szczursonn commented 10 months ago

SOQL's .toValuesOf(field) method returns an empty Set when one of the queried records has the field as null

STEPS TO REPRODUCE

  1. Create two Account records: one where Industry field is null, and one where Industry field is populated
  2. Run a query with .toValuesOf:
    System.debug(SOQL.of(Account.sObjectType).toValuesOf(Account.Industry));
    // {}
  3. Run the same query, but filter out null values from the field:
    System.debug(SOQL.of(Account.sObjectType).whereAre(SOQL.Filter.with(Account.Industry).isNotNull()).toValuesOf(Account.Industry));
    // {Education, Mining, Manufacturing...}

Expected behavior

.toValuesOf(field) returns a Set with all values when extracting a nullable field, including null