Comments (7)
Looks like it doesn't, as per the following unit test. I'll have a play and see if I can make something work.
I'm thinking, because reflective lookups can't be required, the UnitOfWork could do two DML passes on those records. One to insert them and get Ids, and another to backfill the reflective lookups and update if required.
@IsTest
private static void reflectiveLookups()
{
fflib_ISObjectUnitOfWork uow = Application.UnitOfWork.newInstance();
Product_Category__c productCategory1 = TestObjectFactory.createProductCategory( uow );
Product_Category__c productCategory2 = TestObjectFactory.createProductCategory( uow, productCategory1 );
Product_Category__c productCategory3 = TestObjectFactory.createProductCategory( uow, productCategory2 );
uow.commitWork();
productCategory1 = [SELECT Id, Parent_Category__c FROM Product_Category__c WHERE Id = :productCategory1.Id];
productCategory2 = [SELECT Id, Parent_Category__c FROM Product_Category__c WHERE Id = :productCategory2.Id];
productCategory3 = [SELECT Id, Parent_Category__c FROM Product_Category__c WHERE Id = :productCategory3.Id];
System.assertEquals(null, productCategory1.Parent_Category__c);
System.assertEquals(productCategory1.Id, productCategory2.Parent_Category__c, 'The category should be related to a parent category');
System.assertEquals(productCategory2.Id, productCategory3.Parent_Category__c, 'The category should be related to a parent category');
}
System.AssertException: Assertion Failed: The category should be related to a parent category: Expected: a0KO0000004aLS0MAM, Actual: null
from fflib-apex-common.
@afawcett I've added support for reflective lookups to my fork. Can you turn this into a feature request, and I'll do a pull request for review.
from fflib-apex-common.
It's maybe because its been quite a long week, but can you elaborate more on what a 'reflective lookup' is?
from fflib-apex-common.
Phew, tough sprint. Finally got some head space back.
By reflective lookup, I mean a self lookup, or a self relationship. A lookup that points to the same SObjectType on which it's created.
I've patched my fflib fork to handle self lookups and it's working well. Sure there is a performance hit, but I've found doing an insert followed by an update is much friendlier than trying to chain DML inserts within an SObjectType.
from fflib-apex-common.
Thanks @loganm, sounds interesting, looking forward to taking a look at this.
In the meantime have you seen this long standard PR from @adtennant?
from fflib-apex-common.
My solution for cyclic dependancies has been in play on my org for a while now, and hasn't spat the dummy once. So I'll open a pull request of its current state for review.
from fflib-apex-common.
I don't know if this is still true .. please reopen with a repro case if so
from fflib-apex-common.
Related Issues (20)
- Unit test failure in multi-currency org HOT 4
- Deploy button doesn't deploy because there are test failures HOT 1
- Expected a QueryException due to read only user not having access to Opportunity HOT 7
- Switch to Inherited Sharing on SObjectDescribe and SObjectSelector HOT 2
- With latest fflib, do TriggerHandlers become service class consumers? If so what happens to UoW? HOT 6
- Selected tests in fflib_SObjectSelectorTest fail in an org with encryption enabled on Account.Name HOT 2
- Selector Mocks to Include SOQL Query Retrieve Check HOT 1
- fflib_SObjectUnitOfWork doCommitWork executes all dml for all registered types even if there are no changes
- Update README as session recordings are not available HOT 2
- fflib_SObjectDescribe.cls fails to resolve cross-object field paths for Person Accounts
- Aggregate SOQL support. HOT 2
- Disable Savepoint in tests HOT 4
- Inconsistent Code Coverage and Test Failures in fflib-apex-common HOT 1
- fflib_SObjectSelector and fflib_SObjectUnitOfWork have insufficient test code coverage. HOT 2
- Add queryWithBinds to Selector layer HOT 2
- Unit test failing fflib_SecurityUtilsTest & sysadmin_objectAndField_access HOT 8
- Coverage of UnitOfWork class HOT 1
- Versioning HOT 1
- fflib_SObjectSelectorTest failure with Lookup relationship and Person Type Accounts HOT 5
- fflib_SObjectSelectorTest Error: 'Assertion Failed: Expected: 12345.67, Actual: 9117.25' HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fflib-apex-common.