>
> What would it do , INSERT into the parent table, then the child row is
> created implicitly and then.....do an UPDATE to the child table ?   where
> does the stored procedure get the values to be set up for the child row ?
>
>
The trigger is activated on INSERTS only, and creates the child row using
the same id (pk) as the parent row. So, the only mandatory value comes from
the parent row (all other are set with NULL or DEFAULT).


> So yeah I think you'd have to be using a mapper here that doesn't know
> about the second table, or isn't expecting to INSERT into it.
>
> Some pattern like this:
>
> # when we do #1895, this will be possible
> mapper(Base, base_table, polymorphic_on=base_table.c.type)
> mapper(Child, child_table, inherits=Base, polymorphic_identity='child')
> session.add_all([Base(type='child'), Base(type='child'),
> Base(type='child'))
>
> # until then, probably like this:
>
> mapper(InsertChild, base_table)
> mapper(Base, base_table, polymorphic_on=base_table.c.type)
> mapper(Child, child_table, inherits=Base, polymorphic_identity='child')
> session.add_all([InsertBase(type='child'), InsertBase(type='child'),
> InsertBase(type='child'))
>
> c1, c2, c3 = Session.query(Child).all()
>
> You could use MapperExtension to issue an UPDATE to the child table, using
> the connection given, as the InsertBase objects are inserted.
>
> It would all be very inconvenient.    One way to change your stored
> procedure or trigger in a minimal way, depending on the database in use, is
> to either disable the trigger for the connection using a pool listener, or
> have your stored procedure check some connection-wide variable, again which
> you'd set up on each connection using a pool listener.
>
>
Thanks for all the precious tips!

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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