-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add check to disallow field in on_insert() #920
Conversation
@@ -9591,6 +9591,8 @@ def err_multi_anchor_tables : Error< | |||
"A rule may not specify multiple tables or active fields from different tables " | |||
"in 'on_' attributes (on_insert, on_change, or on_update). " | |||
"Ensure that all your active field references belong to the same table.">; | |||
def err_illegal_field_reference : Error< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would strike the name
from the message. I.e. A field may not be referenced in 'on_insert'. The 'on_insert' attribute only accepts a table
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's changed.
@@ -2477,6 +2477,12 @@ class rule_match_handler_t : public MatchFinder::MatchCallback | |||
string table, field, tag; | |||
if (parse_attribute(table_iterator, table, field, tag)) | |||
{ | |||
if (!field.empty()) | |||
{ | |||
gaiat::diag().emit(diag::err_illegal_field_reference); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the source location here is probably good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -9591,6 +9591,8 @@ def err_multi_anchor_tables : Error< | |||
"A rule may not specify multiple tables or active fields from different tables " | |||
"in 'on_' attributes (on_insert, on_change, or on_update). " | |||
"Ensure that all your active field references belong to the same table.">; | |||
def err_illegal_field_reference : Error< | |||
"A field may not be referenced in the 'on_insert' statement. The 'on_insert' attribute only accepts a table.">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is on_insert
a statement or an attribute? It's confusing to call it differently in the same error message. Maybe instead of statement or attribute, we should call it "clause"?
* Add check to disallow field in on_insert() * revert some clang-tidy changes to avoid diffs * another attempt to fix formatting issues * removed unnecessary line of code * responding to PR comments
In the case of
on_insert(tablename.fieldname)
, we are now disallowing thefieldname
, as requested in GAIAPLAT-1396.This emits an error message like:
If the caret should appear below
max_temp
, I can follow up with another commit for this.Note that formatting changes in
main.cpp
are a persistent problem until the file has stable formatting. The changes are an attempt to do that.