Changeset 3139

Show
Ignore:
Timestamp:
01/28/07 21:53:07 (18 years ago)
Author:
jerome
Message:

Fixed a bug which caused edpykota (and other) to fail when
deleting unexisting entries. (The result was correct anyway
because there was nothing to do, but the traceback looked ugly)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/sql.py

    r3133 r3139  
    827827        """Deletes many billing codes.""" 
    828828        codeids = ", ".join(["%s" % self.doQuote(b.ident) for b in billingcodes]) 
    829         self.multipleQueriesInTransaction([  
     829        if codeids : 
     830            self.multipleQueriesInTransaction([  
    830831                    "DELETE FROM billingcodes WHERE id IN (%s)" % codeids,]) 
    831832             
     
    833834        """Deletes many users.""" 
    834835        userids = ", ".join(["%s" % self.doQuote(u.ident) for u in users]) 
    835         self.multipleQueriesInTransaction([  
     836        if userids : 
     837            self.multipleQueriesInTransaction([  
    836838                    "DELETE FROM payments WHERE userid IN (%s)" % userids, 
    837839                    "DELETE FROM groupsmembers WHERE userid IN (%s)" % userids, 
     
    843845        """Deletes many groups.""" 
    844846        groupids = ", ".join(["%s" % self.doQuote(g.ident) for g in groups]) 
    845         self.multipleQueriesInTransaction([  
     847        if groupids : 
     848            self.multipleQueriesInTransaction([  
    846849                    "DELETE FROM groupsmembers WHERE groupid IN (%s)" % groupids, 
    847850                    "DELETE FROM grouppquota WHERE groupid IN (%s)" % groupids, 
     
    851854        """Deletes many printers.""" 
    852855        printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 
    853         self.multipleQueriesInTransaction([  
     856        if printerids : 
     857            self.multipleQueriesInTransaction([  
    854858                    "DELETE FROM printergroupsmembers WHERE groupid IN (%s) OR printerid IN (%s)" % (printerids, printerids), 
    855859                    "DELETE FROM jobhistory WHERE printerid IN (%s)" % printerids, 
     
    862866        printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 
    863867        userids = ", ".join(["%s" % self.doQuote(u.ident) for u in users]) 
    864         self.multipleQueriesInTransaction([  
     868        if userids and printerids : 
     869            self.multipleQueriesInTransaction([  
    865870                    "DELETE FROM jobhistory WHERE userid IN (%s) AND printerid IN (%s)" \ 
    866871                                 % (userids, printerids), 
     
    872877        printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 
    873878        groupids = ", ".join(["%s" % self.doQuote(g.ident) for g in groups]) 
    874         self.multipleQueriesInTransaction([  
     879        if groupids and printerids : 
     880            self.multipleQueriesInTransaction([  
    875881                    "DELETE FROM grouppquota WHERE groupid IN (%s) AND printerid IN (%s)" \ 
    876882                                 % (groupids, printerids),])