sonar-openedge icon indicating copy to clipboard operation
sonar-openedge copied to clipboard

Missing field in query with fields

Open clement-brodu opened this issue 3 years ago • 5 comments

Hello,

It could be a good idea to detect this error :

FOR EACH Customer FIELDS (CustNum) WHERE Customer.CustNum < 10 NO-LOCK:
    /* Customer.Name is missing from FIELDS */
    MESSAGE Customer.CustNum SKIP Customer.Name   VIEW-AS ALERT-BOX INFORMATION BUTTONS OK IN WINDOW CURRENT-WINDOW.
END.

clement-brodu avatar Sep 13 '21 09:09 clement-brodu

Yes, interesting !

gquerret avatar Sep 14 '21 13:09 gquerret

@clement-brodu Just wanted to add a note that if this is a problem you run into in a prod environment I'd suggest enabling the Reread Fields (-rereadfields) parameter. IMO the best practice is to have this turned off in non-prod so errors can be detected, but enabled in prod such that users are not effected by poor choice of fields phrases.

kenherring avatar Sep 15 '21 20:09 kenherring

+1 I wanted to suggest the same rule!

dominickdm avatar Nov 24 '21 07:11 dominickdm

Any news/update on this request? I was going to make a new post, but then I found this one :-)

dominickdm avatar Apr 21 '23 11:04 dominickdm

@dominickdm The current model doesn't keep track of the referenced (or excluded) fields in a query. That has to be added in the model before working on the rule. I'll see how/when that can be done.

gquerret avatar Apr 24 '23 13:04 gquerret