-
Notifications
You must be signed in to change notification settings - Fork 542
Open
Labels
Description
A handy enhancement would be a new fluent method on fflib_QueryFactory that supports the For Update
clause
.addForUpdate()
the addForUdpate
would do a getOrderings().clear()
as you can't Order By
with For Update
. This would avoid code within a Selector class like this:
public override String getOrderby() {return 'OrderItemNumber';}
/* other selector methods here... */
public virtual OrderItem[] selectSomethingCoolAvoidLockingIssues(set<ID> ids) {
fflib_QueryFactory oiQF = newQueryFactory()
.setCondition('Id IN :ids' +
' AND Type__c IN (\'FOO\',\'BAR\')' );
oiQF.getOrderings().clear(); // no Order BY if FOR UPDATE
String soql = oiQF.toSOQL() + ' FOR UPDATE';
return Database.query(soql);
}
medeag and Vacster