rspec/rules/S1738/rule.adoc

24 lines
691 B
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
2021-01-27 13:42:22 +01:00
The main motivation for this rule is to improve the readability of relevant SQL code. From one database optimiser to another, the performance of ``++IN++`` and ``++OR++`` clauses to specify a list of possible values for a column can be slightly different, but this difference is usually very minor. What is not minor is the difference in readability between the two styles, which is why an ``++IN++`` clause is preferred.
2020-06-30 12:47:33 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:47:33 +02:00
----
SELECT * FROM PERSONS
WHERE AGE = 10 OR AGE = 13 OR AGE = 18 OR AGE < 5
----
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:47:33 +02:00
----
SELECT * FROM PERSONS
WHERE AGE IN (10, 13, 18) OR AGE < 5
----