Bugs item #3567422, was opened at 2012-09-13 09:18
Message generated for change (Tracker Item Submitted) made by
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3567422&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: SQLObject release (specify)
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Vroo ()
Assigned to: Nobody/Anonymous (nobody)
Summary: lazyUpdate is resetting fields to default values when read
Initial Comment:
I'm trying to use SQLObject's lazyUpdate feature and my data is getting clobbered. Here's the class definition
class T(sqlobject.SQLObject):
class sqlmeta:
lazyUpdate = True
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
if self.sqlmeta.dirty:
self.syncUpdate()
return False
foo = IntCol()
bar = IntCol(default=None)
The context manager functions are so I can write something like:
with T.select().getOne() as t:
# update t
Everything seems to work fine when I'm creating the objects. However, when I'm just reading the objects, fields with default values (like bar above) are getting reset to their default values.
For example, given
def get_rows():
rows = T.select()
return list(repr(r) for r in rows)
If I call get_rows repeatedly, I find that the first time I get the correct data and subsequent times some or all of the rows have their values replaced by their defaults. Eventually all the rows are reset to defaults. Fields without default values are not touched.
If I comment out the line that sets lazyUpdate in the class definition, it works fine (presumably with many more writes to the db). If I comment out the call to syncUpdate it still fails. Changing the default to a different value (like -1) still fails (and values get reset to -1 not None). It's not some lingering schema setting as I've deleted the table and recreated it multiple times as I've been trying to resolve the problem.
FWIW, I'm using SQLObject 1.3.1, Python 2.7 and PostreSQL 9.1.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3567422&group_id=74338
|