Changeset 3502

Show
Ignore:
Timestamp:
04/12/08 10:32:11 (9 months ago)
Author:
bselby
Message:

Issues with Postgres and MySQL fixed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • peerreviewplugin/branches/2.1-toddler/codereview/ReviewCommentStruct.py

    r2577 r3502  
    5959        #Add information to a new database entry 
    6060        if self.IDComment == "-1": 
    61             query = "INSERT INTO ReviewComments VALUES(NULL,'" + dbEscape(self.IDFile) + "', '" + dbEscape(self.IDParent) + "','" + dbEscape(self.LineNum) + "','" + dbEscape(self.Author) + "','" + dbEscape(self.Text) + "','" + dbEscape(self.AttachmentPath) + "','" + `self.DateCreate` + "')" 
    62             cursor.execute(query) 
     61            cursor.execute("INSERT INTO ReviewComments " 
     62                           "(IDFile, IDParent, LineNum, Author, Text, AttachmentPath, DateCreate) " 
     63                           "VALUES (%s, %s, %s, %s, %s, %s, %s)", 
     64                           (self.IDFile, self.IDParent, self.LineNum, self.Author, self.Text, self.AttachmentPath, self.DateCreate)) 
     65            self.IDComment = db.get_last_id(cursor, 'ReviewComments', 'IDComment') 
    6366            db.commit() 
    64             self.IDComment = cursor.lastrowid; 
    6567        else: 
    6668        #Update information in existing database entry 
    67             query = "UPDATE ReviewComments SET IDFile = '" + dbEscape(self.IDFile) + "', IDParent = '" + dbEscape(self.IDParent) + "', LineNum = '" + dbEscape(self.LineNum) + "', Author = '" + dbEscape(self.Author) + "', Text = '" + dbEscape(self.Text) + "', AttachmentPath = '" + dbEscape(self.AttachmentPath) + "', DateCreate = '" + `self.DateCreate` + "' WHERE IDComment = '" + dbEscape(self.IDComment) + "'" 
    68             cursor.execute(query) 
     69            cursor.execute("UPDATE ReviewComments SET " 
     70                           "IDFile=%s, IDParent=%s, LineNum=%s, Author=%s, Text=%s, AttachmentPath=%s, DateCreate=%s WHERE IDComment=%s", 
     71                           (self.IDFile, self.IDParent, self.LineNum, self.Author, self.Text, self.AttachmentPath, self.DateCreate, self.IDComment)) 
    6972            db.commit() 
    7073        return self.IDComment