Hello,

My question is linked to a previous question asked here 
:https://groups.google.com/forum/#!topic/sqlalchemy/XUHmfrMRhdc.

The context : Horizontal Sharding with dynamic shard (depending of the 
execution context).

All works fine for loading (with the solution given in the other thread) 
but it fails for deletion.

Example : 

class Parent(Base):
    __tablename__ = 'parent'
    id = Column(Integer, primary_key=True)
    children = relationship("Child", lazy=True)
class Child(Base):
    __tablename__ = 'child'
    id = Column(Integer, primary_key=True)
    parent_id = Column(Integer, ForeignKey('parent.id'))


If I want to delete a parent instance (its shard id is know), the orm tries 
to load the children items before (cascade delete). 
To do it, a query is created from the Child mapper 
(LazyLoader._emit_lazyload function).
On query execution, my shard session calls my "query_chooser" function. The 
problem is that I need to got the shard_id from the parent object instance 
and I didn't find it in the query object...

I can solve my problem by overwritting the method "_emit_lazyload" in 
LazyLoader class but I don't know if it is possible and how to do it...

Thanks,

Julien




-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to