rspec/rules/S5393/apex/rule.adoc

40 lines
1.6 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
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++``.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,apex]
2021-04-28 16:49:39 +02:00
----
[Select Id from Case where LastModifiedDate < :mydate]; // Noncompliant
[Select Id from Case where LastModifiedDate <= :mydate]; // Noncompliant
----
== Resources
2021-04-28 16:49:39 +02:00
* 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)
=== Message
Replace this use of LastModifiedDate with SystemModStamp.
endif::env-github,rspecator-view[]