-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Good day,
While using the InsertWithoutColumnsCheck rule, we identified an inconsistency: when inserting an array of values of type %ROWTYPE, the rule checks for the presence of a parent FORALL_STATEMENT directive. However, in cases where the insertion is written in the following format:
declare
type t_tab is table of tab%rowtype index by binary_integer;
v_tab t_tab;
idx integer;
begin
idx := v_tab.first;
while idx is not null loop
insert into tab values v_tab(idx);
idx := v_tab.next;
end loop;
end;
/
the rule triggers a false positive warning: {{Specify the columns in this INSERT.}} although in this case, the absence of an explicit column list is both valid and expected.
A similar issue occurs when analyzing the following code, which does not involve any parent loop construct:
insert into tab values v_tab(1);
Therefore, we suggest improving the rule logic as follows:
Instead of verifying the presence of a FORALL_STATEMENT parent directive, the rule should check the type of the variable used in the VALUES_CLAUSE. Specifically, if the VALUES_CLAUSE contains a METHOD_CALL, the rule should check the datatype of the VARIABLE_NAME. If the datatype is an AssociativeArray with nestedType = Rowtype, then the column list in the INSERT statement should not be required.
Moreover, we believe it would be reasonable to extend the rule further to explicitly prohibit specifying column lists in such cases, as this could lead to bugs if the table structure changes in the future.
If the described issue and the proposed solution seem logical and acceptable, we would be happy to prepare and submit a pull request with the necessary fix.
Thank you for your attention, and we look forward to your feedback!