system.db.runNamedQuery - Project Scope vs Gateway Scope

Hello,
I'm using Ignition v8.1.28. I've found what appears to either be an inconsistency or a bug: system.db.runNamedQuery does not require the project name when run in gateway or client scope if parameters are all provided as positional (contrary to what the docs say).

E.g. the following code will run fine in gateway scope:

value = system.db.runNamedQuery("MyQueryName",{},None,1)

And the following code will fail in gateway scope, with a ProjectNotFoundException:

value = system.db.runNamedQuery("MyQueryName",{},getKey=1)

Both of the above will work when run in a script console in the designer.

I came across this as I had scripts executing in gateway scope which did not have a project name defined, but worked. The documentation seems to suggest that it should not work at all.

Given that it works fine with positional arguments, is there any reason for it to not work with named arguments? Is there any reason to have separate syntax for the two variants?

You can call it a bug. Arguably, it is poor API design, as gateway scopes that are within a project should default to that project. Similar to the handling of data source names in the other system.db.* functions.

3 Likes