Simplify system.db.runNamedQuery Gateway/Project Scope
planned
t
tobias.schneiderheinze
system.db.runNamedQuery is used in two different scenarios that use two different parameter settings: gateway and project. As I do have several scripts running on gateway scope and project scope, I always have to switch between ('project', 'NamedQueryPath', 'params') and ('NamedQueryPath', 'params') because they are incompatible.
PLEASE make the 'project' parameter optional in the project scope.. or better: enable cross reverence to other projects!
Log In
P
Paul Griffith
planned
In 8.3, we're going to introduce a new system function to execute named queries that addresses this scoping incompatibility.
B
Brandon Peterson
I'd like to add that this is a difficult bug to find if you don't know what you're looking for. And "scope" isn't a well understood concept in my experience. I still get confused about it tbh.
Perhaps
system.db.runProjectNamedQuery('NamedQueryPath', 'params')
and system.db.runGatewayNamedQuery('project', 'NamedQueryPath', 'params')
with no
optional arguments could be a viable way forward. It would allow for backwards compatibility and eliminate any ambiguity with optional parameters.Alternatively, I'd recommend checking for valid project names if a named query isn't found so that a more forgiving error message could be raised. Instead of 'Named query "MyProjectName" not found', it could say 'Named query "MyProjectName" not found. Remember: When running system.db.runNamedQuery in a project scope, the project name is implied. Project scope function signature: system.db.runNamedQuery("path/to/named_query", params)'
t
tieushaun
I believe this cannot be fixed with being backwards compatible. Deprecating this and creating a new would be the way to go.
t
tobias.schneiderheinze
and maybe you also wanna correct the last example https://docs.inductiveautomation.com/display/DOC80/system.db.runNamedQuery
This example will run [..] in the Project scope. [..]
Run the Named Query
system.db.runNamedQuery("ProjectName", "myUpdateQuery", params)