File "/var/task/common/repository.py", line 74, in delete_all res = self._session.query(model).delete() File "/opt/python/sqlalchemy/orm/session.py", line 1558, in query return self._query_cls(entities, self, **kwargs) File "/opt/python/sqlalchemy/orm/query.py", line 191, in __init__ self._set_entities(entities) File "/opt/python/sqlalchemy/orm/query.py", line 219, in _set_entities self._set_entity_selectables(self._entities) File "/opt/python/sqlalchemy/orm/query.py", line 250, in _set_entity_selectables ent.setup_entity(*d[entity]) File "/opt/python/sqlalchemy/orm/query.py", line 4187, in setup_entity self._with_polymorphic = ext_info.with_polymorphic_mappers File "/opt/python/sqlalchemy/util/langhelpers.py", line 883, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) File "/opt/python/sqlalchemy/orm/mapper.py", line 2141, in _with_polymorphic_mappers configure_mappers() File "/opt/python/sqlalchemy/orm/mapper.py", line 3255, in configure_mappers mapper._post_configure_properties() File "/opt/python/sqlalchemy/orm/mapper.py", line 1950, in _post_configure_properties prop.init() File "/opt/python/sqlalchemy/orm/interfaces.py", line 196, in init self.do_init() File "/opt/python/sqlalchemy/orm/relationships.py", line 1984, in do_init self._setup_join_conditions() File "/opt/python/sqlalchemy/orm/relationships.py", line 2048, in _setup_join_conditions self._join_condition = jc = JoinCondition( File "/opt/python/sqlalchemy/orm/relationships.py", line 2408, in __init__ self._determine_joins() File "/opt/python/sqlalchemy/orm/relationships.py", line 2504, in _determine_joins self.secondaryjoin = join_condition( File "<string>", line 2, in join_condition File "<string>", line 2, in _join_condition File "/opt/python/sqlalchemy/util/deprecations.py", line 128, in warned return fn(*args, **kwargs) File "/opt/python/sqlalchemy/sql/selectable.py", line 932, in _join_condition constraints = cls._joincond_scan_left_right( File "/opt/python/sqlalchemy/sql/selectable.py", line 987, in _joincond_scan_left_right b.foreign_keys, key=lambda fk: fk.parent._creation_order AttributeError: type object 'BusinessAreaContact' has no attribute 'foreign_keys'
On Tue, Dec 15, 2020 at 8:50 AM Mike Bayer <[email protected]> wrote: > > hey there - > > I don't know what that is. Can you share the complete stack trace? that > would show me where it is misinterpreting something. thanks! > > > > On Tue, Dec 15, 2020, at 7:48 AM, Larry Martell wrote: > > I have this model class: > > class BusinessAreaContact(Base): > __tablename__ = 'BusinessAreaContact' > > businessAreaID = Column(ForeignKey('BusinessArea.businessAreaID'), > primary_key=True, nullable=False) > contactEmail = Column(ForeignKey('Contact.contactEmail'), > primary_key=True, nullable=False) > > If I try and delete from the table with: > > session.query(BusinessAreaContact).delete() > > I get: > > AttributeError: type object 'BusinessAreaContact' has no attribute > 'foreign_keys' > > I have other models where I define FKs in the same way, and I do not > get that error with those. What makes this model different and how can > I fix this error? > > Thanks! -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CACwCsY78enZdOfFZ4Pjx0efTebNyMeTady72z-piiM-VSq6CpA%40mail.gmail.com.
