Fix the item creation SQL call to properly calculate the note count for numNotes()

This commit is contained in:
Dan Stillman 2006-06-27 19:29:05 +00:00
parent d6fa0455e1
commit 672ca5956e

View file

@ -70,7 +70,7 @@ Scholar.Item.prototype.loadFromID = function(id){
var sql = 'SELECT I.*, lastName || '
+ 'CASE ((SELECT COUNT(*) FROM itemCreators WHERE itemID=' + id + ')>1) '
+ "WHEN 0 THEN '' ELSE ' et al.' END AS firstCreator, "
+ "(SELECT COUNT(*) FROM itemNotes WHERE itemID=I.itemID) AS numNotes "
+ "(SELECT COUNT(*) FROM itemNotes WHERE sourceItemID=I.itemID) AS numNotes "
+ 'FROM items I '
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
@ -1279,7 +1279,7 @@ Scholar.Items = new function(){
var sql = 'SELECT I.*, lastName || '
+ 'CASE ((SELECT COUNT(*) FROM itemCreators WHERE itemID=I.itemID)>1) '
+ "WHEN 0 THEN '' ELSE ' et al.' END AS firstCreator, "
+ "(SELECT COUNT(*) FROM itemNotes WHERE itemID=I.itemID) AS numNotes "
+ "(SELECT COUNT(*) FROM itemNotes WHERE sourceItemID=I.itemID) AS numNotes "
+ 'FROM items I '
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '