apex-enterprise-patterns / fflib-apex-common

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

Add method to include ALL ROWS in QueryFactory #409

Closed 1903Daniel closed 2 years ago

1903Daniel commented 2 years ago

We have a use case in our project using FFLIB where we need to query for archived and deleted records as well.

The proposed change adds the ability to call setAllRows(true) on QueryFactory objects, which results in ALL ROWS being appended to the resulting query. It is also possible to reset the property with setAllRows(false) after e.g. deep cloning a QueryFactory.


This change is Reviewable

ImJohnMDaniel commented 2 years ago

@1903Daniel, thanks for the submission. Quick question though: Why should this be added? The Selector Pattern never stipulates that a selector should "query all fields". The Selector Pattern stipulates that there should be a "minimal number of fields queried on this SObject." It also puts the responsibility on the specific selector class implementations to designate which fields should be part of that minimal number of fields queried.

1903Daniel commented 2 years ago

@ImJohnMDaniel Thanks for the comment. As per documentation, ALL ROWS doesn't control which fields should be retrieved. Rather it controls which records should be retrieved (deleted and archived records as well): https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_query_all_rows.htm

So the responsibility for specifying the fields still lies at the developer implementing the Selector class.

ImJohnMDaniel commented 2 years ago

My apologies @1903Daniel. Clearly, I was completely confused about what you were proposing here. I was totally thinking of something completely different. I will reach out to the other reviewers and we can get back to you. Cheers!

1903Daniel commented 2 years ago

@ImJohnMDaniel Thanks a lot 😃 I appreciate the review process

ImJohnMDaniel commented 2 years ago

@1903Daniel -- Thanks for the help!!