Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv14373/SQLObject
Modified Files:
DBConnection.py SQLObject.py
Log Message:
Postgres:
Use lastoid instead of selecting directly from the sequence.
Means you *must* use SERIAL for your ID column, or something that
acts like it (i.e., does an auto increment)
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** DBConnection.py 22 Apr 2003 02:27:10 -0000 1.27
--- DBConnection.py 29 Apr 2003 08:15:10 -0000 1.28
***************
*** 446,458 ****
def _queryInsertID(self, conn, table, idName, names, values):
c = conn.cursor()
- c.execute('SELECT nextval(\'%s_%s_seq\')' % (table, idName))
- (id,) = c.fetchone()
- names.append(idName)
- values.append(id)
q = self._insertSQL(table, names, values)
if self.debug:
print 'QueryIns: %s' % q
c.execute(q)
! return id
def _queryAddLimitOffset(self, query, start, end):
--- 446,456 ----
def _queryInsertID(self, conn, table, idName, names, values):
c = conn.cursor()
q = self._insertSQL(table, names, values)
if self.debug:
print 'QueryIns: %s' % q
c.execute(q)
! c.execute('SELECT %s FROM %s WHERE oid = %s'
! % (idName, table, c.lastoid()))
! return c.fetchone()[0]
def _queryAddLimitOffset(self, query, start, end):
Index: SQLObject.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** SQLObject.py 22 Apr 2003 03:10:01 -0000 1.28
--- SQLObject.py 29 Apr 2003 08:15:11 -0000 1.29
***************
*** 592,596 ****
# There's a write lock. Not sure if I need this...
! self._SO_writeLock.acquire()
self._connection._SO_update(self,
[(self._SO_columnDict[name].dbName,
--- 592,596 ----
# There's a write lock. Not sure if I need this...
! #self._SO_writeLock.acquire()
self._connection._SO_update(self,
[(self._SO_columnDict[name].dbName,
***************
*** 601,605 ****
if self._SO_autoInitDone:
setattr(self, instanceName(name), value)
! self._SO_writeLock.release()
def set(self, **kw):
--- 601,605 ----
if self._SO_autoInitDone:
setattr(self, instanceName(name), value)
! #self._SO_writeLock.release()
def set(self, **kw):
***************
*** 643,649 ****
% (self.__class__.__name__, self.id)
# @@: do we really need this lock?
! self._SO_writeLock.acquire()
results = self._connection._SO_selectOne(self, [self._SO_columnDict[name].dbName])
! self._SO_writeLock.release()
assert results != None, "%s with id %s is not in the database" \
% (self.__class__.__name__, self.id)
--- 643,649 ----
% (self.__class__.__name__, self.id)
# @@: do we really need this lock?
! #self._SO_writeLock.acquire()
results = self._connection._SO_selectOne(self, [self._SO_columnDict[name].dbName])
! #self._SO_writeLock.release()
assert results != None, "%s with id %s is not in the database" \
% (self.__class__.__name__, self.id)
|