On Nov 9, 2012, at 3:45 AM, Werner wrote:

> Hi,
> 
> I don't understand why on one record I don't get the authuser relation.
> 
> My definition is:
> class Cellar(DeclarativeBase, mix.StandardColumnMixin):
>    __tablename__ = u'cellar'
> 
>    name = sa.Column(sa.Unicode(length=50), nullable=False)
>    fk_authuser_id = sautils.reference_col('authuser')
> 
> Cellar.authuser = sao.relationship('Authuser', backref='cellars', primaryjoin=
>            ('Cellar.id==Authuser.fk_cellar_id'), uselist=False)
> 
> In my authuser class I have:
> class Authuser(DeclarativeBase, mix.StandardColumnMixin):
>    __tablename__ = u'authuser'
> 
>    name = sa.Column(sa.Unicode(30), nullable=False, index=True)
> ....
> 
>    # not using reference_col due to the use of Authuser in cellar
>    fk_cellar_id = sa.Column(sa.BigInteger(), sa.ForeignKey(u'cellar.id',
>                                        name='fk_cellar_id', use_alter=True))
> 
> Authuser.cellar = sao.relationship('Cellar', primaryjoin=
>            ('Authuser.fk_cellar_id==Cellar.id'))
> 
> With this query I don't get the authuser relation on the second record even 
> so the fk_authuser_id is set to 1, which is the same as on the first record.

above, fk_authuser_id is used by the Authuser.cellar relationship, not the 
Cellar.authuser relationship.  You'd need fk_cellar_id to be meaningful in that 
case.

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