On 6/18/15 5:04 PM, Kevin Qiu wrote:
Error: SAWarning: Warning: relationship 'staff_obj' on mapper 'Mapper|ProjectApp|PROJECT_APP' supersedes the same relationship on inherited mapper 'Mapper|Application|APPLICATION'; this can cause dependency issues during flush
  self._check_conflicts()

Hi !

Thanks for this email. But I can't do very much with it. First off, I'm assuming the "question" here is, "why am I getting this warning?". The only answer to that at the moment would be what the message itself says; it means you have another relationship called "staff_obj" on the Application class that is conflicting.

We don't see that in your example code, but the example code omits many details such as what the "app_category" object is as well as any kind of foreign key between Application and ProjectApp, so I can only assume that a second "staff_obj" relationship must be in the real code as well. If this is not the case, then you'd need to supply a fully working test case - below I've provided one which you can alter to show me how it is producing this warning when it shouldn't be. The example includes assumed values of the missing elements added back in, and it runs without warnings.

from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class Staff(Base):
    __tablename__ = 'STAFF'
    staff_id = Column(String(20), primary_key=True)


class Application(Base):
    __tablename__ = 'APPLICATION'
    app_id = Column(Integer, primary_key=True)

    # I had to add this because it was missing from the example
    app_category = Column(String)

    __mapper_args__ = {
        'polymorphic_identity': 'application',
        'polymorphic_on': app_category
    }


class ProjectApp(Application):
    __tablename__ = 'PROJECT_APP'

    app_id = Column(Integer, primary_key=True)

    # I had to add this since to support joined table inheritance
    # there needs to be a foreign key relationship
    super_app_id = Column(Integer, ForeignKey('APPLICATION.app_id'))

    # I had to comment this out because there is no C_SUPERVISOR
    # mapping here
# c_supervisor = Column(String(62), ForeignKey('C_SUPERVISOR.c_sup_email'))

    u_supervisor = Column(String(20), ForeignKey('STAFF.staff_id'))
    staff_obj = relationship('Staff', backref='projectapp_objs')
    __mapper_args__ = {
        'polymorphic_identity': 'projApp',
    }

e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)

s = Session(e)
p1, p2, p3 = ProjectApp(), ProjectApp(), ProjectApp()

s.add_all([
    Staff(staff_id='s1', projectapp_objs=[p1, p2]),
    Staff(staff_id='s2', projectapp_objs=[p3]),
])
s.commit()

assert p2.staff_obj.staff_id == 's1'

--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to