rspec/rules/S2454/plsql/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

49 lines
1.0 KiB
Plaintext

== Why is this an issue?
Consistently using aliases for column names is useful for several reasons. The main one is that the code is independant from potential database modifications - when a column has been renamed to comply with standards for instance. Another reason is to remove ambiguity when querying several tables that may have equivalent column names.
=== Noncompliant code example
[source,sql]
----
BEGIN
SELECT
emp.name, -- Noncompliant - should be aliased
dpt.name -- Noncompliant - should be aliased
INTO employeesArray
FROM employee emp INNER JOIN department dpt
ON emp.DepartmentID = dpt.ID;
END;
/
----
=== Compliant solution
[source,sql]
----
BEGIN
SELECT
emp.name employee_name, -- Compliant
dpt.name departement_name -- Compliant
INTO employeesArray
FROM employee emp INNER JOIN department dpt
ON emp.DepartmentID = dpt.ID;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add an alias to "xxx"
endif::env-github,rspecator-view[]