Skip to content

we forgot to make sure select().params() works with ORM relationship elements inside of join() #6124

Closed
@zzzeek

Description

@zzzeek
Member

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.

Activity

added this to the 1.4.x milestone on Mar 24, 2021
sqla-tester

sqla-tester commented on Mar 24, 2021

@sqla-tester
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingorm

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zzzeek@sqla-tester

        Issue actions

          we forgot to make sure select().params() works with ORM relationship elements inside of join() · Issue #6124 · sqlalchemy/sqlalchemy