Yes, just a typo.
The actual problem is the following:

When I try to add back_populates('user') to User.billing_addresses and 
User.shipping_addresses relationships, I get the error:
User.billing_addresses and back-reference Address.user are both of the same 
direction <symbol 'ONETOMANY>.  Did you mean to set remote_side on the 
many-to-one side?

среда, 27 февраля 2019 г., 1:03:40 UTC+7 пользователь Mike Bayer написал:
>
> you are missing and_(): 
>
> billing_addresses = relationship('Address', 
> primary_join='and_(User.id==Address.id, 
> Address.is_billing.is_(True))', uselist=True) 
>
>
> On Tue, Feb 26, 2019 at 5:44 AM Pavel Pristupa <pris...@gmail.com 
> <javascript:>> wrote: 
> > 
> > Hi everybody! 
> > 
> > Is there a way to use primary_join with back_populates in the following 
> case? 
> > 
> > I have two entities (sorry, I may be wrong with the exact syntax): 
> > 
> > 
> > class User(Base): 
> >   id = sa.Column(sa.Integer, primary_key=True) 
> >   billing_addresses = relationship('Address', 
> primary_join='User.id==Address.id, Address.is_billing.is_(True)', 
> uselist=True) 
> >   shipping_addresses = relationship('Address', 
> primary_join='User.id==Address.id, Address.is_billing.is_(False)', 
> uselist=True) 
> > 
> > 
> > class Address(Base): 
> >   id = sa.Column(sa.Integer, primary_key=True) 
> >   is_billing = sa.Column(sa.Boolean)  # Let it be a discriminator for 
> whether it's a billing or shipping 
> >   user_id = sa.Column(sa.Integer, sa.ForeignKey('User.id'), 
> nullable=False) 
> >   user = relationship(User) 
> > 
> > 
> > I had to add uselist=True explicitly, but that's not a problem. 
> > When I try to add back_populates('user') to User.billing_addresses and 
> User.shipping_addresses relationships, I get the error: 
> > User.billing_addresses and back-reference Address.user are both of the 
> same direction <symbol 'ONETOMANY>.  Did you mean to set remote_side on the 
> many-to-one side? 
> > 
> > Could you help me what and where I should fix? 
> > 
> > -- 
> > SQLAlchemy - 
> > The Python SQL Toolkit and Object Relational Mapper 
> > 
> > http://www.sqlalchemy.org/ 
> > 
> > To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description. 
> > --- 
> > 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+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to