Skip to content

ensure query(X).add_entity(Y) produces the same internal state as query(X, Y) #1188

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Anonymous

A has link to B; then

  • query(A,B).join(A.linktoB)
  • query(A).join(A.linktoB).add_entity(B)
  • query(A).add_entity(B).join(A.linktoB)
  • query(B,A).join(B.backtoA)
  • query(B).join(B.backtoA).add_entity(A)
  • query(B).add_entity(A).join(B.backtoA)
    should be equivalent?

if B is not to be aliased / not with_polymorphic, all is ok;
else, above give different results, some nothing, some decart product coming from having both B and Baliased in FROM

svil / az () svilendobrev _com


Attachments: a.py

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Dec 22, 2008

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

here's a patch for this one:

--- lib/sqlalchemy/orm/query.py	(revision 5505)
+++ lib/sqlalchemy/orm/query.py	(working copy)
@@ -113,7 +113,8 @@
                     mapper, selectable, is_aliased_class = _entity_info(entity)
                     if not is_aliased_class and mapper.with_polymorphic:
                         with_polymorphic = mapper._with_polymorphic_mappers
-                        self.__mapper_loads_polymorphically_with(mapper, sql_util.ColumnAdapter(selectable, mapper._equivalent_columns))
+                        if mapper.mapped_table not in self._polymorphic_adapters:
+                            self.__mapper_loads_polymorphically_with(mapper, sql_util.ColumnAdapter(selectable, mapper._equivalent_columns))
                         adapter = None
                     elif is_aliased_class:
                         adapter = sql_util.ColumnAdapter(selectable, mapper._equivalent_columns)
sqlalchemy-bot

sqlalchemy-bot commented on Dec 22, 2008

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • added labels: high priority, orm
  • set milestone to "0.5.xx"
  • changed title from "A.join(A.reftoB) / .add_entity(B) together working" to "ensure query(X).add_entity(Y) produces the same in"
sqlalchemy-bot

sqlalchemy-bot commented on Mar 19, 2010

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed milestone from "0.6.xx" to "0.6.0"
sqlalchemy-bot

sqlalchemy-bot commented on Mar 19, 2010

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

wow what a PITA. used your test pretty much verbatim in ddeaa9f.

sqlalchemy-bot

sqlalchemy-bot commented on Mar 19, 2010

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added this to the 0.6.0 milestone on Nov 27, 2018
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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          ensure query(X).add_entity(Y) produces the same internal state as query(X, Y) · Issue #1188 · sqlalchemy/sqlalchemy