Overload methods to accept Schema.SObjectType and Schema.SObjectField
Nobody has claimed this yet.
- Dominant language
- Apex
- Stars
- 110
- Forks
- 15
- Avg merge
- 1m
- Merged PRs (30d)
- 7
Description
Summary
When a custom object or field is removed from an org, it would be nice for a missed reference to be caught at compile-time. When passing strings to Query Lib, a missed reference will instead fail at runtime. Overloading Query Lib functions with Schema.SObjectType and Schema.SObjectField parameters would enable developers to be confident that their code is using existing objects and fields when it compiles.
Suggested Solution
Overload any functions that take an object type or field api name as a string to have another option to pass in Schema.SObjectType or Schema.SObjectField. For example from SOQL.Builder:
public Builder selectField(Schema.SObjectField field) {
selectField(String.valueOf(field));
return this;
}
and example usage:
SOQL soqlQuery = new SOQL.Builder(My_Custom_Object__c.SObjectType)
.selectFields(new List<Schema.SObjectField>{
My_Custom_Object__c.Id,
My_Custom_Object__c.My_Custom_Field__c
})
.whereCondition(
new Query.Condition()
.equals(My_Custom_Object__c.Id, myId)
)
.build();
Alternative Solutions
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating SOQL.Builder methods that accept object or field API names as strings, then inspect Query.Condition handling for the same pattern. Check how Schema.SObjectType and Schema.SObjectField convert to existing string-based paths. Done means the relevant overloads accept these schema types while preserving current string behavior, with coverage for the example usage.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100