WITH query not supported?

17 views
Skip to first unread message

Emiliano Heyns

unread,
Aug 2, 2026, 8:35:19 PM (2 days ago) Aug 2
to zotero-dev
Are WITH queries not supported in Zotero? In this case:

var q = "WITH CitationKeys AS (SELECT id.itemID, idv.value AS citationKey FROM itemData id JOIN fields f ON id.fieldID = f.fieldID JOIN itemDataValues idv ON id.valueID = idv.valueID WHERE f.fieldName = 'citationKey') SELECT * FROM CitationKeys";
//var q = "SELECT id.itemID, idv.value AS citationKey FROM itemData id JOIN fields f ON id.fieldID = f.fieldID JOIN itemDataValues idv ON id.valueID = idv.valueID WHERE f.fieldName = 'citationKey'";

const rows = await Zotero.DB.queryAsync(q, [], { noParseParams: true })
return rows.length

I would have expected both queries to return the same result, but the first returns `undefined` into rows, while the 2nd gives me the results I expect.

Emiliano Heyns

unread,
Aug 2, 2026, 8:56:21 PM (2 days ago) Aug 2
to zotero-dev
never mind -- wrapping the CTE in a SELECT * FROM (...) does the trick to get the query to be recognized as a SELECT query
Reply all
Reply to author
Forward
0 new messages