Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- content_table = Table('content', metadata,
- Column('id', Integer, primary_key=True),
- Column('locale', String, nullable=False),
- Column('countryId', Integer),
- Column('cat', String),
- useexisting=True
- )
- class Content(object):
- def __init__(self, id=None, locale=None, countryId=None, cat=None, tag=None):
- self.id = id
- self.locale = locale
- self.countryId = countryId
- self.cat = cat
- self.tag = tag
- def __repr__(self):
- return "Content Id %i" % self.id
- mapper(Content, content_table)
- cat_table = Table('cat', metadata,
- Column('id', Integer, primary_key=True),
- Column('name', String(128), nullable=False),
- Column('tag', String(128), nullable=False),
- Column('ranking', Integer(2)),
- useexisting=True
- )
- cat_locale_table = Table('cat_locale', metadata,
- Column('id', Integer, ForeignKey('cat.id'), primary_key=True),
- Column('contentId', None, ForeignKey('content.id')),
- useexisting=True
- )
- class Cat(object):
- def __init__(self, id=None, name=None, tag=None, ranking=None):
- self.id = id
- self.name = name
- self.tag = tag
- self.ranking = ranking
- mapper(Cat, cat_table, properties={
- "contents": relation(Content, lazy=False, secondary=cat_locale_table)
- })
- #### This line throws the following error:
- sa.query(Cat).order_by(Cat.name).options([eagerload('contents')]).all()
- InvalidRequestError: Mapper 'Mapper|Cat|cat' has no property 'contents'
Add Comment
Please, Sign In to add comment