Re: [Sqlalchemy-tickets] [sqlalchemy] #2810: Single Item support for Association Proxy
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-08-26 15:57:43
|
#2810: Single Item support for Association Proxy
----------------------------------+------------------------------------
Reporter: jonathan | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: cextensions | Severity: no triage selected yet
Resolution: | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Comment (by jonathan):
sorry about that.
here's my example, reformatted into a testcase, + your test case in a
single example.
{{{
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
name = Column(String)
a2b_single = relationship("A2B", uselist=False)
a2b_list = relationship("A2B", uselist=True)
b_single = association_proxy("a2b_single", "b")
b_list = association_proxy("a2b_list", "b")
a2b_name = association_proxy("a2b_single", "name")
class A2B(Base):
__tablename__ = 'a2b'
id = Column(Integer, primary_key=True)
id_a = Column(Integer, ForeignKey('a.id'))
id_b = Column(Integer, ForeignKey('b.id'))
name = Column(String)
a = relationship("A", primaryjoin="A2B.id_a==A.id")
b = relationship("B", primaryjoin="A2B.id_b==B.id")
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
name = Column(String)
a1 = A()
assert a1.a2b_name is None
assert a1.b_single is None
assert a1.b_list == []
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2810#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|