Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many to many relation creattion failed #15

Open
shaverlee opened this issue Aug 20, 2014 · 0 comments
Open

many to many relation creattion failed #15

shaverlee opened this issue Aug 20, 2014 · 0 comments

Comments

@shaverlee
Copy link

A typical many to many relation code like this (from Sqlalchemy's documents):

association_table = Table('association', Base.metadata,
Column('left_id', Integer, ForeignKey('left.id')),
Column('right_id', Integer, ForeignKey('right.id'))
)

class Parent(Base):
tablename = 'left'
id = Column(Integer, primary_key=True)
children = relationship("Child",
secondary=association_table)

class Child(Base):
tablename = 'right'
id = Column(Integer, primary_key=True)

after run "gearbox setup-app", the association_table didn't create, and the same code in Application's models worked correctly.
after I study the pluaggble's code, I found in sqla/models.py:

class SQLAModelsSupport(object):
def is_model(self, model):
return inspect.isclass(model) and hasattr(model, 'tablename')

so the subclass of Base has the attribute "tablename", but a instance of Table seems not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant