Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View backref_bug
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# -*- coding: utf-8 -*-
 
from sqlalchemy import create_engine, Integer, Column, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
 
 
engine = create_engine('sqlite://')
 
Base = declarative_base()
 
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
 
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
a_id = Column(Integer, ForeignKey(A.id))
a = relationship(A, backref='bbb')
 
print B.a
 
try:
print A.bbb
except AttributeError:
print "Yep, AttributeError"
else:
raise Exception("The bug is fixed!")
 
A.__mapper__.relationships
print "Now it is loaded: ", A.bbb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.