Hi. Let me explain problem I have with an order of insert statements
created by SQLA which looks as random one. Inserts are generated for
the root object, and its children obviously.
Conference - ConferenceLang (one-to-many)
Conference - Participant (one-to-many)

<code>
        self.confs_t = Table('confs', self.metadata, autoload=True,
autoload_with=config['pylons.g'].sa_engine)
        mapper(Conference, self.confs_t,
               properties = {
                'conf_langs' : relation(ConferenceLang, cascade='all,
delete-orphan', lazy=False),
                'participants' : relation(ConferenceParticipant,

primaryjoin=self.confs_t.c.id == self.conf_parts_t.c.cf_id,

foreign_keys=[self.conf_parts_t.c.cf_id],
                                          cascade='all, delete-orphan'),
               }
        )
        conference = Conference(....)
        conference.conf_langs.append(ConferenceLang(...))
        conference.participants.append(ConferenceParticipant(...))
        .....
        dbsession.flush(conference)
</code>

Without going into details, here's each db session's sequence of 3 inserts:
1st:           INSERT INTO conferences (id, .....
2nd or 3rd: INSERT INTO conf_langs (cf_id, ...)         <- sometimes
as the 2nd statement, and sometimes as the 3rd
2nd or 3rd: INSERT INTO participants (cf_id, ...)        <- same as above

Problem is, that in my db - with some constraints not seen above - I
need to put data first into /conf_langs/ table, and only after then
into /participants/ table.
But instead, SQLAlchemy picks these inserts randomly. Sometimes it
issues an insert into /participants/ first, and sometimes as a
second/third statement.

Do I have control over this behaviour? Or am I doing sth wrong?
Thanks for any help..Tomasz


SQLAlchemy-0.4.8-py2.5.egg, transactional, autoload, Pylons 0.9.6.1,
MySql innodb.



-- 
_i______'simplicity_is_the_key'__________tomasz_nazar
_ii____'i_am_concern_oriented'________________JKM-UPR
_iii__'patsystem.sf.net'___________________linux_user
_'aspectized.com'___________________________prevayler

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to