String IDs and getFirstCreatorSQL()

20 views
Skip to first unread message

Frank Bennett

unread,
May 20, 2013, 11:19:12 AM5/20/13
to zoter...@googlegroups.com
While testing a document with embedded metadata and a missing library item (in MLZ), I saw that the getFirstCreatorSQL() code was failing because a random string of characters was an "unknown column".

If I read the code correctly, integration.js provides a random string ID for missing items:

  https://github.com/zotero/zotero/blob/master/chrome/content/zotero/xpcom/integration.js#L2342

The string is then written into a literal SQL command in Items._load():

  https://github.com/zotero/zotero/blob/master/chrome/content/zotero/xpcom/data/items.js#L757

The error goes away if the string IDs are wrapped in quotes in the SQL. I guess the right way would be to use SQL placeholders, and let the database layer handle the data type?

(I've tested only in MLZ so far, but it looks like the same error would throw in mainline Zotero. Doesn't seem to cause any harm, but I thought I'd mention it.)

Frank

Frank Bennett

unread,
May 20, 2013, 12:07:53 PM5/20/13
to zoter...@googlegroups.com
I've testing with 4.0, and get the same error. Steps to reproduce:

(1) Open a document and add an item from My Library
(2) Delete the item from My Library, and empty trash
(3) Return to document, open the item for editing and open the Classic View.
(4) The "OK" button will be greyed out, no item shows in the selected list (the right-hand box), and the error will show in Web Developer -> Error Console

The item can be manipulated (to add a page locator etc) with the Quick View dialog. But the Classic View provides the only way of reordering entries currently, so citations with missing items cannot be edited in that respect.

I see now that the error thrown on the string ID is only part of the problem: getFirstCreator() is needed to generate the Classic View listings, and even if fixed to get around the string ID thing, it still returns nothing, so an entry for the item cannot be generated. Not sure how one would go about fixing this one. If reorder-by-drag were implemented/fixed in the Quick View dialog, that would make the breakage in Classic View less of an issue though.

Frank

Simon Kornblith

unread,
May 23, 2013, 11:31:24 PM5/23/13
to zoter...@googlegroups.com
I fixed drag and drop in the QuickFormat dialog. The patch is pretty big, and with the DOM range API edge cases are quite likely, so please test.

The classic add citation dialog isn't going to show citations that aren't in the library until we have document collections.

Simon
Reply all
Reply to author
Forward
0 new messages