Closed
Description
I think we can find some way to lightly step-over the relationship for this case, as it's just within the join arguments:
import sqlalchemy as sa
from sqlalchemy.orm import declarative_base, relationship
Base = declarative_base()
class Parent(Base):
__tablename__ = "parent"
id = sa.Column(sa.Integer, primary_key=True)
class Child(Base):
__tablename__ = "child"
id = sa.Column(sa.Integer, primary_key=True)
parent_id = sa.Column(sa.Integer, sa.ForeignKey("parent.id"))
parent = relationship("Parent")
statement = sa.select([Child.id]).join(Child.parent).where(Parent.id == sa.bindparam("id"))
statement = statement.params(id=10)
now an additional thing would be, if there is a relationship() with a bindparam in the primaryjoin or secondaryjoin. But I don't know that I want to get into that - it would mean that we really should be stating the relationship arguments inside of the join params using the same approach as _raw_columns, that is, we put the primaryjoin in there and then annotate it with the relationship. but this of course doesn't work for secondaryjoin and it would deeply impact the join mechanics so for now I would want to ignore this part of it.
this is not a regression since this is a select() using new 1.4-only features.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
sqla-tester commentedon Mar 24, 2021
Mike Bayer has proposed a fix for this issue in the master branch:
Support visit_name on PropComparator to work in cloning https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2673