diff --git a/fflib/src/classes/fflib_QueryFactory.cls b/fflib/src/classes/fflib_QueryFactory.cls index adcccfc..770474c 100644 --- a/fflib/src/classes/fflib_QueryFactory.cls +++ b/fflib/src/classes/fflib_QueryFactory.cls @@ -61,15 +61,15 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr **/ public Schema.SObjectType table {get; private set;} @testVisible - private Set fields; + private Set fields; private String conditionExpression; private Integer limitCount; private Integer offset; private List order; /** - /* Integrate checking for READ Field Level Security within the selectField(s) methods - /* This can optionally be enforced (or not) by calling the setEnforceFLS method prior to calling - /* one of the selectField or selectFieldset methods. + * Integrate checking for READ Field Level Security within the selectField(s) methods + * This can optionally be enforced (or not) by calling the setEnforceFLS method prior to calling + * one of the selectField or selectFieldset methods. **/ private Boolean enforceFLS; @@ -84,39 +84,51 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr private Schema.ChildRelationship relationship; private Map subselectQueryMap; - private QueryField getFieldToken(String fieldName){ - QueryField result; + private String getFieldPath(String fieldName){ if(!fieldName.contains('.')){ //single field Schema.SObjectField token = fflib_SObjectDescribe.getDescribe(table).getField(fieldName.toLowerCase()); if(token == null) throw new InvalidFieldException(fieldName,this.table); if (enforceFLS) fflib_SecurityUtils.checkFieldIsReadable(this.table, token); - result = new QueryField(token); - }else{ //traversing FK relationship(s) - List fieldPath = new List(); - Schema.sObjectType lastSObjectType = table; - Iterator i = fieldName.split('\\.').iterator(); - while(i.hasNext()){ - String field = i.next(); - Schema.SObjectField token = fflib_SObjectDescribe.getDescribe(lastSObjectType).getField(field.toLowerCase()); - if (token != null && enforceFLS) - fflib_SecurityUtils.checkFieldIsReadable(lastSObjectType, token); - if(token != null && i.hasNext() && token.getDescribe().getSOAPType() == Schema.SOAPType.ID){ - lastSObjectType = token.getDescribe().getReferenceTo()[0]; //if it's polymorphic doesn't matter which one we get - fieldPath.add(token); - }else if(token != null && !i.hasNext()){ - fieldPath.add(token); - }else{ - if(token == null) - throw new InvalidFieldException(field,lastSObjectType); - else - throw new NonReferenceFieldException(lastSObjectType+'.'+field+' is not a lookup or master-detail field but is used in a cross-object query field.'); - } + return token.getDescribe().getName(); + } + + //traversing FK relationship(s) + List fieldPath = new List(); + Schema.sObjectType lastSObjectType = table; + Iterator i = fieldName.split('\\.').iterator(); + while(i.hasNext()){ + String field = i.next(); + Schema.SObjectField token = fflib_SObjectDescribe.getDescribe(lastSObjectType).getField(field.toLowerCase()); + DescribeFieldResult tokenDescribe = token != null ? token.getDescribe() : null; + + if (token != null && enforceFLS) { + fflib_SecurityUtils.checkFieldIsReadable(lastSObjectType, token); + } + + if(token != null && i.hasNext() && tokenDescribe.getSOAPType() == Schema.SOAPType.ID){ + lastSObjectType = tokenDescribe.getReferenceTo()[0]; //if it's polymorphic doesn't matter which one we get + fieldPath.add(tokenDescribe.getRelationshipName()); + }else if(token != null && !i.hasNext()){ + fieldPath.add(tokenDescribe.getName()); + }else{ + if(token == null) + throw new InvalidFieldException(field,lastSObjectType); + else + throw new NonReferenceFieldException(lastSObjectType+'.'+field+' is not a lookup or master-detail field but is used in a cross-object query field.'); } - result = new QueryField(fieldPath); } - return result; + + return String.join(fieldPath,'.'); + } + + @TestVisible + private static String getFieldTokenPath(Schema.SObjectField field){ + if(field == null){ + throw new InvalidFieldException('Invalid field: null'); + } + return field.getDescribe().getName(); } /** @@ -138,7 +150,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr **/ public fflib_QueryFactory(Schema.SObjectType table){ this.table = table; - fields = new Set(); + fields = new Set(); order = new List(); enforceFLS = false; } @@ -192,7 +204,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fieldName the API name of the field to add to the query's SELECT clause. **/ public fflib_QueryFactory selectField(String fieldName){ - fields.add( getFieldToken(fieldName) ); + fields.add( getFieldPath(fieldName) ); return this; } /** @@ -206,7 +218,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr throw new InvalidFieldException(null,this.table); if (enforceFLS) fflib_SecurityUtils.checkFieldIsReadable(table, field); - fields.add( new QueryField(field) ); + fields.add( getFieldTokenPath(field) ); return this; } /** @@ -214,12 +226,9 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fieldNames the Set of field API names to select. **/ public fflib_QueryFactory selectFields(Set fieldNames){ - List fieldList = new List(); - Set toAdd = new Set(); for(String fieldName:fieldNames){ - toAdd.add( getFieldToken(fieldName) ); + fields.add( getFieldPath(fieldName) ); } - fields.addAll(toAdd); return this; } /** @@ -227,10 +236,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * @param fieldNames the List of field API names to select. **/ public fflib_QueryFactory selectFields(List fieldNames){ - Set toAdd = new Set(); for(String fieldName:fieldNames) - toAdd.add( getFieldToken(fieldName) ); - fields.addAll(toAdd); + fields.add( getFieldPath(fieldName) ); return this; } /** @@ -244,7 +251,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr throw new InvalidFieldException(); if (enforceFLS) fflib_SecurityUtils.checkFieldIsReadable(table, token); - this.fields.add( new QueryField(token) ); + this.fields.add( getFieldTokenPath(token) ); } return this; } @@ -259,7 +266,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr throw new InvalidFieldException(); if (enforceFLS) fflib_SecurityUtils.checkFieldIsReadable(table, token); - this.fields.add( new QueryField(token) ); + this.fields.add( getFieldTokenPath(token) ); } return this; } @@ -281,7 +288,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr for(Schema.FieldSetMember field: fieldSet.getFields()){ if(!allowCrossObject && field.getFieldPath().contains('.')) throw new InvalidFieldSetException('Cross-object fields not allowed and field "'+field.getFieldPath()+'"" is a cross-object field.'); - fields.add( getFieldToken(field.getFieldPath()) ); + fields.add( getFieldPath(field.getFieldPath()) ); } return this; } @@ -328,7 +335,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr /** * @returns the selected fields **/ - public Set getSelectedFields() { + public Set getSelectedFields() { return this.fields; } @@ -483,7 +490,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr **/ public fflib_QueryFactory addOrdering(String fieldName, SortOrder direction, Boolean nullsLast){ order.add( - new Ordering(getFieldToken(fieldName), direction, nullsLast) + new Ordering(getFieldPath(fieldName), direction, nullsLast) ); return this; } @@ -501,7 +508,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr **/ public fflib_QueryFactory addOrdering(SObjectField field, SortOrder direction, Boolean nullsLast){ order.add( - new Ordering(new QueryField(field), direction, nullsLast) + new Ordering(getFieldTokenPath(field), direction, nullsLast) ); return this; } @@ -520,7 +527,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr **/ public fflib_QueryFactory addOrdering(String fieldName, SortOrder direction){ order.add( - new Ordering(getFieldToken(fieldName), direction) + new Ordering(getFieldPath(fieldName), direction) ); return this; } @@ -539,7 +546,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr **/ public fflib_QueryFactory addOrdering(SObjectField field, SortOrder direction){ order.add( - new Ordering(new QueryField(field), direction) + new Ordering(getFieldTokenPath(field), direction) ); return this; } @@ -553,24 +560,23 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr //if no fields have been added, just add the Id field so that the query or subquery will not just fail if (fields.size() == 0){ if (enforceFLS) fflib_SecurityUtils.checkFieldIsReadable(table, 'Id'); - result += 'Id '; - }else if(sortSelectFields){ - List fieldsToQuery = new List(fields); - fieldsToQuery.sort(); //delegates to QueryFilter's comparable implementation - for(QueryField field:fieldsToQuery){ - result += field + ', '; - } - }else{ - for (QueryField field : fields) - result += field + ', '; + result += 'Id'; + }else { + List fieldsToQuery = new List(fields); + + if(sortSelectFields){ + fieldsToQuery.sort(); + } + + result += String.join(fieldsToQuery,', '); } if(subselectQueryMap != null && !subselectQueryMap.isEmpty()){ for (fflib_QueryFactory childRow : subselectQueryMap.values()){ - result += ' (' + childRow.toSOQL() + '), '; + result += ', (' + childRow.toSOQL() + ') '; } } - result = result.substring(0,result.length()-2) + ' FROM ' + (relationship != null ? relationship.getRelationshipName() : table.getDescribe().getName()); + result += ' FROM ' + (relationship != null ? relationship.getRelationshipName() : table.getDescribe().getName()); if(conditionExpression != null) result += ' WHERE '+conditionExpression; @@ -616,7 +622,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr public class Ordering{ private SortOrder direction; private boolean nullsLast; - private QueryField field; + private String field; public Ordering(String sobjType, String fieldName, SortOrder direction){ this( @@ -629,32 +635,23 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr * Once constructed it's properties may not be modified. **/ public Ordering(Schema.SObjectField field, SortOrder direction){ - this(field, direction, false); //SOQL docs state NULLS FIRST is default behavior + this(fflib_QueryFactory.getFieldTokenPath(field), direction, false); //SOQL docs state NULLS FIRST is default behavior } public Ordering(Schema.SObjectField field, SortOrder direction, Boolean nullsLast){ - this(new QueryField(field), direction, nullsLast); + this(fflib_QueryFactory.getFieldTokenPath(field), direction, nullsLast); } @testVisible - private Ordering(QueryField field, SortOrder direction){ + private Ordering(String field, SortOrder direction){ this(field, direction, false); } @testVisible - private Ordering(QueryField field, SortOrder direction, Boolean nullsLast){ + private Ordering(String field, SortOrder direction, Boolean nullsLast){ this.direction = direction; this.field = field; this.nullsLast = nullsLast; } - /** - * @deprecated - * Use of this method is discouraged. Only the first field of any cross-object fields is returned. - * Use getFields() instead. - **/ - public Schema.SObjectField getField(){ - System.debug(LoggingLevel.WARN, 'fflib_QueryFactory.Ordering.getField is deprecated and should not be used.'); - return field.getBaseField(); - } - public List getFields(){ - return this.field.getFieldPath(); + public String getField(){ + return this.field; } public SortOrder getDirection(){ return direction; @@ -665,103 +662,6 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr } - public class QueryField implements Comparable{ - List fields; - - /** - * The first field in the path to to field being queried - **/ - public SObjectField getBaseField(){ - return fields[0]; - } - - /** - * The full list of fields representing the path to the field being queried - **/ - public List getFieldPath(){ - return fields.clone(); - } - - @testVisible - private QueryField(List fields){ - if(fields == null || fields.size() == 0) - throw new InvalidFieldException('Invalid field: null'); - this.fields = fields.clone(); //don't let clients mutate after setting! - } - @testVisible - private QueryField(Schema.SObjectField field){ - if(field == null) - throw new InvalidFieldException('Invalid field: null'); - fields = new List{ field }; - } - public override String toString(){ - String result = ''; - Integer size = fields.size(); - for (Integer i=0; i0) - { - if (result.endsWithIgnoreCase('Id')) - result = result.removeEndIgnoreCase('Id'); - else if (result.endsWithIgnoreCase('__c')) { - result = result.removeEndIgnoreCase('__c') + '__r'; - } - result += '.'; - } - result += fields[i].getDescribe().getName(); - } - return result; - } - public integer hashCode(){ - return String.valueOf(this.fields).hashCode(); - } - public boolean equals(Object obj){ - //Easy checks first - if(obj == null || !(obj instanceof QueryField)) - return false; - - if (this === obj) - return true; - - //Detailed checks - QueryField other = (QueryField)obj; - Integer size = fields.size(); - if (size != other.fields.size()) - return false; - - for (Integer i=0; i sizeOther) - return 1; - - return this.toString().compareTo(other.toString()); - } - } public class InvalidFieldException extends Exception{ private String fieldName; @@ -775,4 +675,4 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr public class InvalidFieldSetException extends Exception{} public class NonReferenceFieldException extends Exception{} public class InvalidSubqueryRelationshipException extends Exception{} -} +} \ No newline at end of file diff --git a/fflib/src/classes/fflib_QueryFactoryTest.cls b/fflib/src/classes/fflib_QueryFactoryTest.cls index 4f21576..84aeab7 100644 --- a/fflib/src/classes/fflib_QueryFactoryTest.cls +++ b/fflib/src/classes/fflib_QueryFactoryTest.cls @@ -35,6 +35,16 @@ private class fflib_QueryFactoryTest { qf.selectFields( new Set{'acCounTId', 'account.name'} ); qf.selectFields( new List{'homePhonE','fAX'} ); qf.selectFields( new List{ Contact.Email, Contact.Title } ); + System.assertEquals(new Set{ + 'FirstName', + 'LastName', + 'AccountId', + 'Account.Name', + 'HomePhone', + 'Fax', + 'Email', + 'Title'}, + qf.getSelectedFields()); } @isTest @@ -143,7 +153,7 @@ private class fflib_QueryFactoryTest { String query = qf.toSOQL(); System.assertEquals(2,qf.getOrderings().size()); - System.assertEquals(Contact.name,qf.getOrderings()[0].getField() ); + System.assertEquals('Name',qf.getOrderings()[0].getField() ); System.assertEquals(fflib_QueryFactory.SortOrder.DESCENDING,qf.getOrderings()[1].getDirection() ); @@ -207,56 +217,27 @@ private class fflib_QueryFactoryTest { System.assertNotEquals(null,e); } - @isTest - static void invalidFields_noQueryFields(){ - Exception e; - List sObjectFields = new List(); - try { - fflib_QueryFactory.QueryField qfld = new fflib_QueryFactory.QueryField(sObjectFields); - } catch (Exception ex) { - e = ex; - } - System.assertNotEquals(null,e); - } - @isTest static void invalidFields_noQueryField(){ - Exception e; - Schema.SObjectField sObjectField; try { - fflib_QueryFactory.QueryField qfld = new fflib_QueryFactory.QueryField(sObjectField); - } catch (Exception ex) { - e = ex; - } - System.assertNotEquals(null,e); + String path = fflib_QueryFactory.getFieldTokenPath(null); + System.assert(false,'Expected InvalidFieldException; none was thrown'); + } + catch (fflib_QueryFactory.InvalidFieldException ife) { + //Expected + } + catch (Exception e){ + System.assert(false,'Expected InvalidFieldException; ' + e.getTypeName() + ' was thrown instead: ' + e); + } } @isTest - static void invalidFields_queryFieldsNotEquals(){ - Exception e; - Schema.SObjectField sObjectField; - fflib_QueryFactory.QueryField qfld = new fflib_QueryFactory.QueryField(Contact.Name); - fflib_QueryFactory.QueryField qfld2 = new fflib_QueryFactory.QueryField(Contact.LastName); + static void queryFieldsNotEquals(){ + String qfld = fflib_QueryFactory.getFieldTokenPath(Contact.Name); + String qfld2 = fflib_QueryFactory.getFieldTokenPath(Contact.LastName); System.assert(!qfld.equals(qfld2)); } - @isTest - static void queryIdFieldNotEquals(){ - //this is the equivalent of calling setField('account.name'), where table = Contact - fflib_QueryFactory.QueryField qfld = new fflib_QueryFactory.QueryField(new List{ - Schema.Contact.SObjectType.fields.AccountId, - Schema.Account.SObjectType.fields.name - }); - String fldString = qfld.toString(); - } - - @isTest - static void queryIdFieldNotEqualsWrongObjType(){ - fflib_QueryFactory.QueryField qfld = new fflib_QueryFactory.QueryField(new List{ - Schema.Contact.SObjectType.fields.AccountId}); - System.assert(!qfld.equals(new Contact())); - } - @isTest static void addChildQueriesWithChildRelationship_success(){ Account acct = new Account(); @@ -308,7 +289,9 @@ private class fflib_QueryFactoryTest { qf.subselectQuery('Tasks').selectField('Id').selectField('Subject').setCondition(' IsDeleted = false '); List queries = qf.getSubselectQueries(); System.assert(queries != null); - List contacts = Database.query(qf.toSOQL()); + String soql = qf.toSOQL(); + System.debug(soql); + List contacts = Database.query(soql); System.assert(contacts != null && contacts.size() == 1); System.assert(contacts[0].Tasks.size() == 1); System.assert(contacts[0].Tasks[0].Subject == 'test'); @@ -557,14 +540,19 @@ private class fflib_QueryFactoryTest { .addOrdering(new fflib_QueryFactory.Ordering('Contact','name',fflib_QueryFactory.SortOrder.ASCENDING) ) .addOrdering(Contact.LastModifiedDate,fflib_QueryFactory.SortOrder.DESCENDING) .addOrdering(Contact.CreatedDate,fflib_QueryFactory.SortOrder.DESCENDING, true); - Set fields = qf.getSelectedFields(); + Set fields = qf.getSelectedFields(); fflib_QueryFactory.Ordering ordering = new fflib_QueryFactory.Ordering('Contact','name',fflib_QueryFactory.SortOrder.ASCENDING); - ordering.getFields(); - for (fflib_QueryFactory.QueryField qfRow : fields) { - SObjectField fld = qfRow.getBaseField(); - List flds = qfRow.getFieldPath(); - break; - } + System.assertEquals('Name',ordering.getField()); + + System.assertEquals(new Set{ + 'CreatedBy.Name', + 'LastModifiedById', + 'LastModifiedDate', + 'LastName', + 'Id', + 'FirstName'}, + fields); + System.assert(qf.toSOQL().containsIgnoreCase('NULLS LAST')); } @@ -612,37 +600,9 @@ private class fflib_QueryFactoryTest { fflib_QueryFactory qf = new fflib_QueryFactory(Contact.SObjectType); qf.assertIsAccessible().setEnforceFLS(true).setCondition( 'name like \'%test%\'' ).addOrdering('CreatedDate',fflib_QueryFactory.SortOrder.DESCENDING); String query = qf.toSOQL(); - System.assert(query.containsIgnoreCase('Id FROM')); + System.assert(query.containsIgnoreCase('SELECT Id FROM Contact'),'Expected \'SELECT Id FROM Contact\' in the SOQL, found: ' + query); } - @isTest - static void queryField_compareTo(){ - String otherType = 'bob'; - fflib_QueryFactory.QueryField qf = new fflib_QueryFactory.QueryField(Contact.SObjectType.fields.Name); - fflib_QueryFactory.QueryField joinQf = new fflib_QueryFactory.QueryField(new List{ - Contact.SObjectType.fields.LastModifiedById, - Account.SObjectType.fields.OwnerId, - User.SObjectType.fields.Name - }); - fflib_QueryFactory.QueryField otherJoinQf = new fflib_QueryFactory.QueryField(new List{ - Contact.SObjectType.fields.AccountId, - Account.SObjectType.fields.CreatedById, - User.SObjectType.fields.Name - }); - System.assertEquals(-2, qf.compareTo(otherType)); - System.assertEquals(-2, qf.compareTo(null)); - System.assertEquals(0, qf.compareTo(qf)); - System.assertEquals( - 0, - qf.compareTo(new fflib_QueryFactory.QueryField(Contact.SObjectType.fields.Name)), - 'An equal but non-identical instance should return 0' - ); - System.assertEquals(-1 , qf.compareTo(joinQf)); - System.assertEquals(1, joinQf.compareTo(qf)); - System.assert(joinQf.compareTo(otherJoinQf) > 0); - System.assert(otherJoinQf.compareTo(joinQf) < 0); - } - @isTest static void deterministic_toSOQL(){ fflib_QueryFactory qf1 = new fflib_QueryFactory(User.SObjectType); @@ -658,9 +618,8 @@ private class fflib_QueryFactoryTest { }); } String expectedQuery = - 'SELECT ' - +'FirstName, Id, LastName, ' //less joins come first, alphabetically - +'CreatedBy.ManagerId, CreatedBy.Name, LastModifiedBy.Email ' //alphabetical on the same number of joinrs' + 'SELECT CreatedBy.ManagerId, CreatedBy.Name, ' + +'FirstName, Id, LastModifiedBy.Email, LastName ' +'FROM User'; System.assertEquals(qf1.toSOQL(), qf2.toSOQL()); System.assertEquals(expectedQuery, qf1.toSOQL()); @@ -745,11 +704,11 @@ private class fflib_QueryFactoryTest { System.assert(query2.containsIgnoreCase('Fax')); System.assertEquals(2, qf.getOrderings().size()); - System.assertEquals(Contact.name, qf.getOrderings()[0].getField() ); + System.assertEquals('Name', qf.getOrderings()[0].getField() ); System.assertEquals(fflib_QueryFactory.SortOrder.DESCENDING, qf.getOrderings()[1].getDirection()); System.assertEquals(2, qf2.getOrderings().size()); - System.assertEquals(Contact.Fax, qf2.getOrderings()[1].getField()); + System.assertEquals('Fax', qf2.getOrderings()[1].getField()); System.assertEquals(fflib_QueryFactory.SortOrder.ASCENDING, qf2.getOrderings()[1].getDirection()); } diff --git a/fflib/src/classes/fflib_SObjectSelector.cls b/fflib/src/classes/fflib_SObjectSelector.cls index 80b2eb1..66d642b 100644 --- a/fflib/src/classes/fflib_SObjectSelector.cls +++ b/fflib/src/classes/fflib_SObjectSelector.cls @@ -179,52 +179,6 @@ public abstract with sharing class fflib_SObjectSelector return m_enforceCRUD; } - /** - * Provides access to the builder containing the list of fields base queries are using, this is demand - * created if one has not already been defined via setFieldListBuilder - * - * @depricated See newQueryFactory - **/ - public fflib_StringBuilder.FieldListBuilder getFieldListBuilder() - { - List sObjectFields = new List(); - for(fflib_QueryFactory.QueryField queryField : newQueryFactory().getSelectedFields()) - sObjectFields.add(queryField.getBaseField()); - return new fflib_StringBuilder.FieldListBuilder(sObjectFields); - } - - /** - * Use this method to override the default FieldListBuilder (created on demand via getFieldListBuilder) with a custom one, - * warning, this will bypass anything getSObjectFieldList or getSObjectFieldSetList returns - * - * @depricated See newQueryFactory - **/ - public void setFieldListBuilder(fflib_StringBuilder.FieldListBuilder fieldListBuilder) - { - // TODO: Consider if given the known use cases for this (dynamic selector optomisation) if it's OK to leave this as a null operation - } - - /** - * Returns in string form a comma delimted list of fields as defined via getSObjectFieldList and optionally getSObjectFieldSetList - * - * @depricated See newQueryFactory - **/ - public String getFieldListString() - { - return getFieldListBuilder().getStringValue(); - } - - /** - * Returns in string form a comma delimted list of fields as defined via getSObjectFieldList and optionally getSObjectFieldSetList - * @param relation Will prefix fields with the given relation, e.g. MyLookupField__r - * - * @depricated See newQueryFactory - **/ - public String getRelatedFieldListString(String relation) - { - return getFieldListBuilder().getStringValue(relation + '.'); - } - /** * Returns the string representaiton of the SObject this selector represents **/ @@ -420,4 +374,4 @@ public abstract with sharing class fflib_SObjectSelector return queryFactory; } -} +} \ No newline at end of file diff --git a/fflib/src/classes/fflib_SObjectSelectorTest.cls b/fflib/src/classes/fflib_SObjectSelectorTest.cls index 92268c8..7d6bece 100644 --- a/fflib/src/classes/fflib_SObjectSelectorTest.cls +++ b/fflib/src/classes/fflib_SObjectSelectorTest.cls @@ -28,15 +28,6 @@ private with sharing class fflib_SObjectSelectorTest { - static testMethod void testGetFieldListString() - { - Testfflib_SObjectSelector selector = new Testfflib_SObjectSelector(); - String fieldListString = selector.getFieldListString(); - assertFieldListString(fieldListString, null); - String relatedFieldListString = selector.getRelatedFieldListString('myprefix'); - assertFieldListString(relatedFieldListString, 'myprefix'); - } - static testMethod void testGetSObjectName() { Testfflib_SObjectSelector selector = new Testfflib_SObjectSelector(); @@ -175,12 +166,6 @@ private with sharing class fflib_SObjectSelectorTest System.assertEquals(true, selector.isEnforcingCRUD()); System.assertEquals(false, selector.isIncludeFieldSetFields()); - String fieldListString = selector.getFieldListString(); - assertFieldListString(fieldListString, null); - - String relatedFieldListString = selector.getRelatedFieldListString('LookupField__r'); - assertFieldListString(relatedFieldListString, 'LookupField__r'); - System.assertEquals('Account', selector.getSObjectName()); System.assertEquals(Account.SObjectType, selector.getSObjectType2()); }