Closed pgajek2 closed 1 year ago
I see two problems with these solutions: — Unnecessary complexity — Additional code, which is essentially duplicated
Following your examples: This:
.with(field1, field2, field3, field4, field5)
Is not so much different than this:
.with(new List<SObjectField>{
field1, field2, field3, field4, field5
})
But first solution requires much more code from the library, and we want to keep it light. If user wants to add less fields and just write less than full list declaration, then there is possibility of chaining .with
. Same goes for usability, instead of simple completion that shows .with(field)
, .with(list)
, IDE would show list with multiple input fields totally messing simplicity of current solution.
The SOQL library has two methods to specify a field:
.with(SObjectField field)
.with(List<SObjectField> fields)
It requires a
List<SObjectField>
to add more than one field.Of course, you can chain methods:
However, it is still not very clean.
Enhancement
Most of the queries require up to five fields.
Add methods like:
.with(SObjectField field1, SObjectField field2)
.with(SObjectField field1, SObjectField field2, SObjectField field3)
.with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4)
.with(SObjectField field1, SObjectField field2, SObjectField field3, SObjectField field4, SObjectField field5)
So, the usage looks more like native SOQL:
BEFORE:
AFTER: