Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload methods to accept Schema.SObjectType and Schema.SObjectField #245

Open
CSigelmann opened this issue Aug 2, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@CSigelmann
Copy link

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

@CSigelmann CSigelmann added the enhancement New feature or request label Aug 2, 2024
Copy link

github-actions bot commented Aug 2, 2024

Thank you for posting this issue. 🙇🏼‍♂️
We will get back to you shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant