Bugs item #3567422, was opened at 2012-09-13 09:18
Message generated for change (Comment added) made by phd
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: Works For Me
Priority: 5
Private: No
Submitted By: Vroo ()
Assigned to: Oleg Broytman (phd)
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.
----------------------------------------------------------------------
>Comment By: Oleg Broytman (phd)
Date: 2012-10-03 11:02
Message:
And without reliable way to reproduce the problem I cannot provide a fix.
I
cannot even be sure it's a problem in SQLObject and not in your program or
other libraries. Please demonstrate the bug.
----------------------------------------------------------------------
Comment By: Vroo ()
Date: 2012-10-03 10:50
Message:
This resolution is not helpful. It doesn't work for me. This is a
catastrophic failure. It doesn't reset the data on every read but it always
does eventually.
Without a fix, I have no choice but to stop using sqlobject.
----------------------------------------------------------------------
Comment By: Oleg Broytman (phd)
Date: 2012-09-21 11:48
Message:
I cannot reproduce the problem; SQLObject 1.3.0, SQLite, Postgres. Can you
write a simple test scripts (or a pair of scripts -- an initialization and
a test) that demonstrates the problem? As simple as possible, i.e. without
making the table a context manager and so on.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3567422&group_id=74338
|