def test_foreign_keys_with_col(self):

        class Booking(Base):
            __tablename__ = 'booking'
            id = Column(Integer, primary_key=True)

        class PlanBooking(Booking):
            __tablename__ = 'plan_booking'
            id = Column(Integer, ForeignKey(Booking.id),
                        primary_key=True)

        # referencing PlanBooking.id gives us the column
        # on plan_booking, not booking
        class FeatureBooking(Booking):
            __tablename__ = 'feature_booking'
            id = Column(Integer, ForeignKey(Booking.id),
                        primary_key=True)
            plan_booking_id = Column(Integer,
                                     ForeignKey(PlanBooking.id))

            plan_booking = relationship(PlanBooking,
                                        backref='feature_bookings')

        assert FeatureBooking.__table__.c.plan_booking_id.\
            references(PlanBooking.__table__.c.id)

        assert FeatureBooking.__table__.c.id.\
            references(Booking.__table__.c.id)
Test that foreign keys that reference a literal 'id' subclass
dataset/ETHPy150Open zzzeek/sqlalchemy/test/ext/declarative/test_inheritance.py/DeclarativeInheritanceTest.test_foreign_keys_with_col