On 8/6/15 1:50 PM, Richard Gerd Kuesters wrote:
well, i ran today into an issue i never seen before.
considering this simple example:
session = get_session()
objs = []
for ign in xrange(10):
o = NewObject()
objs.append(o)
session.add_all(objs)
session.commit()
for obj in objs:
print obj in session
this will print True only in the first iteration. basically, the other
objects are not bound to a session anymore. is there any reason for
this, or am i doing something wrong?
cant reproduce:
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class NewObject(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)
session = Session(e)
objs = []
for ign in xrange(10):
o = NewObject()
objs.append(o)
session.add_all(objs)
session.commit()
for obj in objs:
print obj in session
output:
<sql stuff...>
2015-08-06 14:28:58,563 INFO sqlalchemy.engine.base.Engine COMMIT
True
True
True
True
True
True
True
True
True
True
best regards,
richard.
--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.