-
Notifications
You must be signed in to change notification settings - Fork 888
parseQuery: Return either a query or an error #178
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
Conversation
@@ -382,7 +382,7 @@ func parseQuery(c core.Catalog, stmt nodes.Node, source string) (*Query, error) | |||
} | |||
case nodes.UpdateStmt: | |||
default: | |||
return nil, nil | |||
return nil, fmt.Errorf("parseQuery: unsupported statement type: %T", n) |
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.
Maybe add a note that here and above you should file an issue if you hit this error because it's easy to see someone generating code that (should be) valid but hitting an edge case here because we haven't thought about it.
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.
That makes sense because with #179, these edge cases shouldn't be hit at all. Now the user gets the following error if it happens though:
parseQuery: unsupported statement type: pg_query.CreateStmt - feel free to file an issue on GitHub
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.
Thanks for the fix! Can we actually remove the - feel free to file an issue on GitHub
from the error message? Instead of a small message for a select number of errors, I'd like to include a larger error message with links back to the project. Since that's a larger project, it should be a separate change.
Done, the error messages are uniformly again now. |
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.
Thanks for quick turnaround
This fixes #174 and #176.
parseQuery
used to return anil
query and anil
error, however the code relies on the assumption that the query is always valid if the error is notnil
(as explained here).This assumption gets correct with this change.
parseQuery
returns either a query or and error. There's noreturn nil, nil
anymore.