When does Zotero.DB.queryAsync return undefined?

11 views
Skip to first unread message

Emiliano Heyns

unread,
Feb 12, 2026, 11:47:18 AM (6 days ago) Feb 12
to zotero-dev
I am executing this

    await Zotero.DB.executeTransaction(async () => {
      await Zotero.DB.queryAsync('ATTACH DATABASE ? AS betterbibtex', [ db ])
      const rows = await Zotero.DB.queryAsync(`
        SELECT bbt.itemID, bbt.itemKey, bbt.libraryID, bbt.citationKey, bbt.pinned
        FROM betterbibtex.citationkey bbt
        JOIN items item ON item.itemID = bbt.itemID
        WHERE item.itemID NOT IN (SELECT itemID FROM deletedItems)
          AND item.itemID NOT IN (SELECT itemID FROM feedItems)
          AND item.itemTypeID NOT IN (
            SELECT itemTypeID
            FROM itemTypes
            WHERE typeName IN ('attachment', 'note', 'annotation')
          )
      `.replace(/\n/g, ' '))

but rows is `undefined`. Under what conditions can this plausibly happen? I can run this query in the sqlite cli without issue.

Abe Jellinek

unread,
Feb 12, 2026, 11:53:36 AM (6 days ago) Feb 12
to zoter...@googlegroups.com
queryAsync() checks what operator (SELECT, INSERT, etc.) your statement is using, and it doesn’t expect there to be a space at the beginning. Call trim().

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/zotero-dev/40331328-4354-4552-840e-b9749e90a095n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages