Relationship between classes with __bind_key__ defined throws InvalidRequestError #1367
Unanswered
graedo-ogd
asked this question in
Q&A
Replies: 1 comment
-
If you are doing something like this: class_d = db.Table(
'class_d',
Column('b_id', Integer, ForeignKey(
'class_b.id'), primary_key=True),
Column('c_id', Integer, ForeignKey(
'class_c.id'), primary_key=True),
bind_key="auth"
)
class ClassB(db.Model):
__bind_key__ = "auth"
id: Mapped[int] = mapped_column(primary_key=True)
text: Mapped[str] = mapped_column(unique=True, nullable=False)
manyc: Mapped[List["ClassC"]] = relationship(
secondary=class_d, back_populates="manyb")
class ClassC(db.Model):
__bind_key__ = "auth"
id: Mapped[int] = mapped_column(primary_key=True)
text: Mapped[str] = mapped_column(unique=True, nullable=False)
manyb: Mapped[List["ClassB"]] = relationship(
secondary=class_d, back_populates="manyc") it works. Any suggestion? I mean it's a workaround, but with all classes defined without a bind key it works proper. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When defining a relationship between two classes via association class and query to one of them it raise the InvalidRequestError exception.
Define a minimal flask app, with six (three as default and three with bind key) classes and a second bind for the configuration.
Traceback:
When removing the
relationship
from classes with bind key it works.Also tested with creating tables.
Environment:
Beta Was this translation helpful? Give feedback.
All reactions