tablename reports unqualified fields in FIELDS()

Project:Prolint Issue Tracker
Component:Rules
Category:bug report
Priority:normal
Assigned:jurjen
Status:closed
Description

Code such as:
FOR EACH Customer FIELDS(Id Name) NO-LOCK:

reports that the "Id" and "Name" should be qualified with table name.

But it is safe as FIELDS statements can only apply to the table specified and if a field is specified that does not exist in the table the code will not compile.

e.g.
FOR EACH Customer FIELDS(banana) NO-LOCK:

results in:
syntax error "** Field banana does not exist in table Company. (442)

Please amend this rule to ignore FIELDS statements.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jurjen's picture

#1

Assigned to:Anonymous» jurjen
Status:active» fixed

fixed and checked in into the subversion repository as revision 327.
http://websvn.oehive.org/listing.php?repname=prolint&rev=327

Although the false positive is now fixed for the FIELDS option, it still exists for the EXCEPT option in the record-phrase. That is because the EXCEPT keyword can be used in many different statements so Prolint would have to determine for sure if EXCEPT is used in the context of a record-phrase. Unfortunately this is not so easy.


john's picture

#2

I think it would be safe to do. I searched for EXCEPT in this:
http://www.joanju.com/dist/docs/tree_spec.html

Unless I'm missing something (quite possible) then it looks to me like the pragma should be added for all direct Field_ref nodes of EXCEPT nodes, right?

Rather than use a deep Proparse query for any Field_ref nodes, look for all direct children of an EXCEPT node. If it is a Field_ref node, then add the pragma. The ExcludeExcept part of that rule looks specifically for BUFFER-COPY, which doesn't seem necessary, though I only glanced at the code so I might not be understanding it all.


jurjen's picture

#3

I don't know. It would be easy to do as you suggest and mark each field_ref in each EXCEPT but it is hard for me to predict if that might cause false negatives.
I searched the EXCEPT option in the OpenEdge help file and found it in many statements like ENABLE, INSERT, SET, UPDATE, PROMPT-FOR and more. I am not sure but I think some of those statements accept not only fieldnames but also variables in the EXCEPT option, or fieldnames from several table buffers, and in those cases the fieldnames should be qualified with a tablename.


#4

Status:fixed» closed