rspec/rules/S5393/apex/rule.adoc

34 lines
1.5 KiB
Plaintext

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++``.
== Noncompliant Code Example
----
[Select Id from Case where LastModifiedDate < :mydate]; // Noncompliant
[Select Id from Case where LastModifiedDate <= :mydate]; // Noncompliant
----
== 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]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]