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.
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.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
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.
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.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Sorry about that. I've never used a bug tracking system before that hides the conversation so I didn't see your comment. All I saw was the resolution change. It repros very reliably in my program. I can't give you my whole program but I can try and pare it down.
Yes, SF tracker is not the best tool for beginners; it takes some time to master it. The smaller script you can provide the better. Waiting...
Any progress with test scripts?