rspec/rules/S5393/apex/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

40 lines
1.6 KiB
Plaintext

== Why is this an issue?
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
[source,apex]
----
[Select Id from Case where LastModifiedDate < :mydate]; // Noncompliant
[Select Id from Case where LastModifiedDate <= :mydate]; // Noncompliant
----
== Resources
* 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[]