rspec/rules/S5393/apex/rule.adoc

25 lines
1.3 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
The ``++SystemModStamp++`` and ``++LastModifiedDate++`` are similar in that they store last modification dates of a record. The main difference is that ``++LastModifiedDate++`` is only updated when users update a record, not when automated system do it.
This means that 'LastModifiedDate +<=+ SystemModStamp' but it is not possible to have 'LastModifiedDate > SystemModStamp'
The ``++SystemModStamp++`` field is indexed, whereas ``++LastModifiedDate++`` is not. In most case when an SOQL query filters on ``++LastModifiedDate++``, the index of ``++SystemModStamp++`` will be used instead. This however does not apply when the filter is of the form ``++where LastModifiedDate < :mydate++`` because ``++SystemModStamp++`` can be greater than ``++LastModifiedDate++``.
This rule raises an issue when an SOQL query has a ``++where++`` filter with a condition of the form ``++LastModifiedDate < :mydate++`` or ``++LastModifiedDate <= :mydate++``.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
[Select Id from Case where LastModifiedDate < :mydate]; // Noncompliant
[Select Id from Case where LastModifiedDate <= :mydate]; // Noncompliant
----
2021-04-28 16:49:39 +02:00
== See
* https://developer.salesforce.com/blogs/engineering/2014/11/force-com-soql-performance-tips-systemmodstamp-vs-lastmodifieddate-2.html[Force.com SOQL Performance Tips: LastModifiedDate vs SystemModStamp]