Skip to content

Commit b12e68e

Browse files
committed
Removed the ability to get all fields for an SObject - a field set must be provided
Having a way to get all fields could be very problematic if an org has a high number of fields. Field sets provided much more control, so I'll use them to drive QueryGenerator.cls
1 parent c868427 commit b12e68e

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

src/classes/QueryGenerator.cls

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,15 @@ public class QueryGenerator {
22

33
private Schema.FieldSet fieldSet;
44
private SObjectType sobjectType;
5-
private Schema.DescribeSObjectResult sobjectResult;
65
private Set<String> queryFields;
76

8-
public QueryGenerator(Schema.DescribeSObjectResult sobjectResult) {
9-
this(sobjectResult, null);
10-
}
11-
127
public QueryGenerator(Schema.FieldSet fieldSet) {
13-
this(null, fieldSet);
14-
}
15-
16-
private QueryGenerator(Schema.DescribeSObjectResult sobjectResult, Schema.FieldSet fieldSet) {
178
this.fieldSet = fieldSet;
18-
this.sobjectResult = sobjectResult;
199

20-
this.sobjectType = fieldSet != null ? fieldSet.getSObjectType() : sobjectResult.getSObjectType();
10+
this.sobjectType = fieldSet.getSObjectType();
2111
this.queryFields = new Set<String>{'Id'}; // Always add the ID field, just in case it's not in the field set
2212

23-
if(this.fieldSet == null) this.parseSObjectFields();
24-
else this.parseFieldSetMembers();
13+
this.parseFieldSetMembers();
2514
}
2615

2716
public String buildQuery() {
@@ -38,12 +27,6 @@ public class QueryGenerator {
3827
return query;
3928
}
4029

41-
public void parseSObjectFields() {
42-
for(Schema.SObjectField sobjectField : this.sobjectResult.fields.getMap().values()) {
43-
this.queryFields.add(sobjectField.getDescribe().getName());
44-
}
45-
}
46-
4730
private void parseFieldSetMembers() {
4831
if(this.fieldSet == null) return;
4932

0 commit comments

Comments
 (0)