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.
q = session.query(db.Cellar)
for i in q:
print i.name
print i.fk_authuser_id
print i.authuser.name
The output is:
Main Cellar
1
default
Special Reserve
1
--- attribute error NoneType object has no attribute 'name'
I am still on 0.7.9.
What am I doing wrong?
Werner
--
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.