Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

Changeset 200

Show
Ignore:
Timestamp:
03/20/06 02:01:50
Author:
fumanchu
Message:

Fix for #55 (MySQL auto_increment is wonky). Turns out that LAST_INSERT_ID is connection-specific.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/storage/storemysql.py

    r199 r200  
    242242        fields = ", ".join(fields) 
    243243        values = ", ".join(values) 
     244         
     245        conn = self.connection() 
    244246        self.execute('INSERT INTO %s (%s) VALUES (%s);' % 
    245                      (str(tablename), fields, values)) 
     247                     (str(tablename), fields, values), 
     248                     conn) 
    246249         
    247250        # Grab the new ID. This is threadsafe because db.reserve has a mutex. 
    248         data, col_defs = self.fetch("SELECT LAST_INSERT_ID();") 
    249         setattr(unit, cls.identifiers[0], data[0][0]) 
     251        setattr(unit, cls.identifiers[0], conn.insert_id()) 
    250252     
    251253    #                               Schemas                               #