Edgewall Software

Ticket #288: bitten-postgres8.3.patch

File bitten-postgres8.3.patch, 3.7 KB (added by anonymous, 5 years ago)

Patch for type casting

  • bitten/model.py

    diff -U3 -r bitten.orig/bitten/model.py bitten.patched/bitten/model.py
    old new  
    217217            handle_ta = False 
    218218 
    219219        cursor = db.cursor() 
    220         cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (self.id,)) 
     220        cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (str(self.id),)) 
    221221        cursor.execute("DELETE FROM bitten_platform WHERE id=%s", (self.id,)) 
    222222        if handle_ta: 
    223223            db.commit() 
     
    241241        self.id = db.get_last_id(cursor, 'bitten_platform') 
    242242        if self.rules: 
    243243            cursor.executemany("INSERT INTO bitten_rule VALUES (%s,%s,%s,%s)", 
    244                                [(self.id, propname, pattern, idx) 
     244                               [(str(self.id), propname, pattern, idx) 
    245245                                for idx, (propname, pattern) 
    246246                                in enumerate(self.rules)]) 
    247247 
     
    263263        cursor = db.cursor() 
    264264        cursor.execute("UPDATE bitten_platform SET name=%s WHERE id=%s", 
    265265                       (self.name, self.id)) 
    266         cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (self.id,)) 
     266        cursor.execute("DELETE FROM bitten_rule WHERE id=%s", (str(self.id),)) 
    267267        if self.rules: 
    268268            cursor.executemany("INSERT INTO bitten_rule VALUES (%s,%s,%s,%s)", 
    269                                [(self.id, propname, pattern, idx) 
     269                               [(str(self.id), propname, pattern, idx) 
    270270                                for idx, (propname, pattern) 
    271271                                in enumerate(self.rules)]) 
    272272 
     
    288288        platform = TargetPlatform(env, config=row[0], name=row[1]) 
    289289        platform.id = id 
    290290        cursor.execute("SELECT propname,pattern FROM bitten_rule " 
    291                        "WHERE id=%s ORDER BY orderno", (id,)) 
     291                       "WHERE id=%s ORDER BY orderno", (str(id),)) 
    292292        for propname, pattern in cursor: 
    293293            platform.rules.append((propname, pattern)) 
    294294        return platform 
     
    417417        cursor.execute("INSERT INTO bitten_build (config,rev,rev_time,platform," 
    418418                       "slave,started,stopped,status) " 
    419419                       "VALUES (%s,%s,%s,%s,%s,%s,%s,%s)", 
    420                        (self.config, self.rev, int(self.rev_time), 
     420                       (self.config, str(self.rev), int(self.rev_time), 
    421421                        self.platform, self.slave or '', self.started or 0, 
    422422                        self.stopped or 0, self.status)) 
    423423        self.id = db.get_last_id(cursor, 'bitten_build') 
     
    494494        if config is not None: 
    495495            where_clauses.append(("config=%s", config)) 
    496496        if rev is not None: 
    497             where_clauses.append(("rev=%s", rev)) 
     497            where_clauses.append(("rev=%s", str(rev))) 
    498498        if platform is not None: 
    499499            where_clauses.append(("platform=%s", platform)) 
    500500        if slave is not None: 
  • bitten/tests/model.py

    diff -U3 -r bitten.orig/bitten/tests/model.py bitten.patched/bitten/tests/model.py
    old new  
    186186        self.assertEqual(('test', 'Windows XP'), cursor.fetchone()) 
    187187 
    188188        cursor.execute("SELECT propname,pattern,orderno FROM bitten_rule " 
    189                        "WHERE id=%s", (platform.id,)) 
     189                       "WHERE id=%s", (str(platform.id),)) 
    190190        self.assertEqual((Build.OS_NAME, 'Windows', 0), cursor.fetchone()) 
    191191        self.assertEqual((Build.OS_VERSION, 'XP', 1), cursor.fetchone()) 
    192192