On Jan 19, 2011, at 1:29 PM, AgentOrange wrote:

> Hi ho,
> 
> Thanks for the swift reply!
> 
>> Did you use uselist=False on foo.bar and the associationproxy? It would nice 
>> if you could show some 
>> code.http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html?h...
> 
> Yes I did. The code is more complicated as it has a bunch of other
> stuff in it, but here's a condensation:
> 
> class Foo(Base):
>    id = Column(Integer, primary_key = True)
>    foo_bar_join = relationship(FooBar, primaryjoin = (id ==
> FooBar.id_foo), uselist = False)
>    bar = association_proxy('foo_bar_join', 'bar', creator = lambda x:
> FooBar(bar = x) )
> 
> class Bar(Base):
>    id = Column(Integer, primary_key = True)
> 
> class FooBar(Base):
>    id_foo = Column(Integer, ForeignKey('foo.id'), primary_key = True)
>    id_bar = Column(Integer, ForeignKey('bar.id'), primary_key = True)
> 
>    bar = relationship(Bar, primaryjoin = (id_bar == Bar.id))
>    other_stuff = Column(Integer)
> 
> The problem comes if you try to fetch 'bar' from an instance of 'Foo'
> for which there is no entry in the "foo_bar" join table.

Maybe you can squelch the exception by using a synonym with the descriptor 
argument to map to a fake property.

Cheers,
M

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