[sqlalchemy] Re: autoflush during instanciation
I quite sure I'm not using it... Look at that code that reproduce the bug http://utilitybase.com/paste/11481 The last line (p2 = Parent(p)) leads to a load of the children, so an autoflush. I have a failure with 0.5.2: sqlalchemy.exc.IntegrityError: (IntegrityError) parent.dumb may not be NULL u'INSERT INTO parent (dumb) VALUES (?)' [None] which let me think the object was somehow added to the autoflush... I hope that will help to solve this. GustaV --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: autoflush during instanciation
that's the cascade of p2 being added to the session upon being associated with the in-session items in p.children. So yes, cascade rules do add things to the session. setting cascade=None on Child.parent would prevent it, or alternatively you can turn off autoflush on the session for the span of the __init__ method by just setting the .autoflush attribute to False. On Jan 29, 2009, at 5:55 AM, GustaV wrote: I quite sure I'm not using it... Look at that code that reproduce the bug http://utilitybase.com/paste/11481 The last line (p2 = Parent(p)) leads to a load of the children, so an autoflush. I have a failure with 0.5.2: sqlalchemy.exc.IntegrityError: (IntegrityError) parent.dumb may not be NULL u'INSERT INTO parent (dumb) VALUES (?)' [None] which let me think the object was somehow added to the autoflush... I hope that will help to solve this. GustaV --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: autoflush during instanciation
On Jan 28, 10:45 am, GustaV buisson.guilla...@gmail.com wrote: Hi all, In the __init__ method of a mapper, the load of a relation may lead to an autoflush operation. When it happens, the object being instanciated is already in the session and so INSERTed in the flush, whereas it is not initialised completly (still in __init__). only if you're using Session.mapper, which I wouldn't. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: autoflush during instanciation
I'm using Declarative extension actually. In the pylons framework, the session initialise like this def init_model(engine): Call me before using any of the tables or classes in the model sm = orm.sessionmaker(autoflush=True, autocommit=False, bind=engine) meta.engine = engine meta.Session = orm.scoped_session(sm) On 28 jan, 16:46, Michael Bayer zzz...@gmail.com wrote: On Jan 28, 10:45 am, GustaV buisson.guilla...@gmail.com wrote: Hi all, In the __init__ method of a mapper, the load of a relation may lead to an autoflush operation. When it happens, the object being instanciated is already in the session and so INSERTed in the flush, whereas it is not initialised completly (still in __init__). only if you're using Session.mapper, which I wouldn't. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: autoflush during instanciation
On Jan 28, 2009, at 11:21 AM, GustaV wrote: I'm using Declarative extension actually. In the pylons framework, the session initialise like this def init_model(engine): Call me before using any of the tables or classes in the model sm = orm.sessionmaker(autoflush=True, autocommit=False, bind=engine) meta.engine = engine meta.Session = orm.scoped_session(sm) that's all unrelated. Nothing is added to the Session implicitly upon __init__ unless you are using the Session.mapper function, a function I've removed from almost all documentation and will likely be sending into deprecation soon. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---