Hello Group,
I see the following behaviour which I can not explain (don't know
sqlalchemy too well though):
I have the following table setup (heavily simplified):
class WikiPage(Base):
__tablename__ = 'wiki_page'
id = Column(Integer, primary_key=True)
name = Column(Unicode(40))
content = Column(UnicodeText())
def method_that_changes_something(self,...):
....
class Problem(WikiPage):
__tablename__ = 'problem'
__mapper_args__ = {'polymorphic_identity': 'problem'}
id = Column(Integer, ForeignKey('wiki_page.id'), primary_key=True)
Sometimes (so far only when run from a nose test suite) when I query
like this:
problem = self.Session.query(Problem).filter_by(id=problem_id).first()
where problem_id is None. I receive the unexpected result:
- not problem is False
- when applying str to the result I get: <my_app.model.Problem object
at 0x1040db710>
- there should be no Problems with id Null (though currently not
InnoDB tables, all pending changes have been commited and I do not see
any rows with NULL Ids in the DB)
- when I try to access problem.id I get: AttributeError: 'NoneType'
object has no attribute 'id'
- the same when I try to access problem.name
- problem.method_that_changes_something can be called and does
something (on an object that has been inserted before this query but
this is already commited)
- adding sleep(1) before the query changes nothing (so it does not
seem to be a race condition)
Environement:
- Sqlalchemy 0.5.8 or 0.6.2 (behaves the same)
- Pylons 1.0
- MySQL Python 1.2.3
So my questsions are:
- Am I doing something wrong?
- How can I persuade nosetests to output sqlalchemy log messages?
Thanks
Stefan
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.