# \[BUG-13570\] system.db.runQuery vs system.db.runNamedQuery differing return types

**URL:** <https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161>\
**Category:** Ignition\
**Tags:** ignition79, ignition80, scripting\
**Created:** [April 15, 2019, 6:51pm UTC](https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161 "2019-04-15T18:51:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Beck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_beck/32/7813_2.png) [@Steve\_Beck](https://forum.inductiveautomation.com/u/Steve_Beck)\
**Post date:** [April 15, 2019, 6:51pm UTC](https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161/1 "2019-04-15T18:51:47Z")

</div>

Why does running a select query using system.db.runQuery return a pyDataset while running a select query using system.db.runNamedQuery returns a dataset?

I built an entire script starting with a query using system.db.runQuery and then after I was done I moved the query into a named query and expected the script to continue working. I ended up having to make several changes. While this wasn’t a huge problem it begs the question: Why the difference? If I run the same select query in either script it would be simpler if they both returned the same thing.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 15, 2019, 7:07pm UTC](https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161/2 "2019-04-15T19:07:28Z")

</div>

It’s probably a mistake/bug that the Dataset you get from `runNamedQuery` is not a PyDataset under the hood.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 15, 2019, 7:11pm UTC](https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161/3 "2019-04-15T19:11:24Z")

</div>

If it’s not too late, you can work around this using `system.dataset.toPyDataSet()`.

---

<div class="post-metadata">

**Author:** ![Steve\_Beck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_beck/32/7813_2.png) [@Steve\_Beck](https://forum.inductiveautomation.com/u/Steve_Beck)\
**Post date:** [April 15, 2019, 7:19pm UTC](https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161/4 "2019-04-15T19:19:10Z")

</div>

This is essentially what I ended up doing. FWIW, the documentation for these scripting functions does correctly say that they return differing data types.

---

<div class="post-metadata">

**Author:** ![tyrel.parker](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@tyrel.parker](https://forum.inductiveautomation.com/u/tyrel.parker)\
**Post date:** [October 16, 2019, 10:43pm UTC](https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161/5 "2019-10-16T22:43:55Z")

</div>

Would it be possible to add the option of how I want the data returned like I can with a query binding?

ie. I’d like to specify that the result is returned as a json. I can do this using a query binding but not via script.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 16, 2019, 10:50pm UTC](https://forum.inductiveautomation.com/t/bug-13570-system-db-runquery-vs-system-db-runnamedquery-differing-return-types/24161/6 "2019-10-16T22:50:35Z")

</div>

Seems like a reasonable [feature request](https://ideas.inductiveautomation.com). It would probably be easy to implement because somewhere in the Perspective module the logic for turning a Dataset into JSON already exists…
