apex-enterprise-patterns / fflib-apex-common

Common Apex Library supporting Apex Enterprise Patterns and much more!
BSD 3-Clause "New" or "Revised" License
913 stars 517 forks source link

Query Selector cant select FieldDefintiion QualifiedAPI Name for custom metadata selector #240

Closed pranayjswl007 closed 1 year ago

pranayjswl007 commented 5 years ago

It looks like the selector pattern is not compatible with Entity Definition and Field Definition Code:

Code:

flib_QueryFactory queryFactory = newQueryFactory();
  queryFactory = queryFactory.selectField('FieldName__c.QualifiedApiName');

Exception:

Error on line 119, column 1: fflib_QueryFactory.NonReferenceFieldException: OmniPriority__mdt.FieldName__r is not a lookup or master-detail field but is used in a cross-object query field.
Class.fflib_QueryFactory.getFieldPath: line 119, column 1
Class.fflib_QueryFactory.selectField: line 207, column 1
Class.OmniPrioritySelector: line 28, column 1
AnonymousBlock: line 1, column 1
ImJohnMDaniel commented 5 years ago

Have you tried updating the fflib_QueryFactory__c API version to 47.0?

kamell commented 4 years ago

Hi @pranayjswl007, I saw there is an issue already opened for this. The problem is in fflib_QueryFactory().getFieldPath(). For a entity related or metadata related field, the "__r" relationship returns STRING rather than ID (probably a product bug) so that's the issue.

joeythomaschaske commented 4 years ago

Related to https://github.com/apex-enterprise-patterns/fflib-apex-common/issues/208

daveespo commented 1 year ago

This sounds like the same thing as #208 -- I'm going to go ask for a repro case over there and close this as a duplicate