diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2021-12-27 00:24:24 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-12-27 00:24:24 +0000 |
| commit | 2bb6cfc7c9b8f09eaa4efeffc337a1162993979c (patch) | |
| tree | 2a1a87d72ce233d82db085f914d07f7db7b60c08 /lib/sqlalchemy | |
| parent | 818d62be00530549aa52dd5d981819010e4ae484 (diff) | |
| parent | c1d2fbac4c399b47f4715f7ea2a1147374d2aa43 (diff) | |
| download | sqlalchemy-2bb6cfc7c9b8f09eaa4efeffc337a1162993979c.tar.gz | |
Merge "include empty intermediary tables in optimized get" into main
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 60083bf4d..40a76181c 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -3022,23 +3022,28 @@ class Mapper( allconds = [] + start = False + + # as of #7507, from the lowest base table on upwards, + # we include all intermediary tables. + + for mapper in reversed(list(self.iterate_to_root())): + if mapper.local_table in tables: + start = True + elif not isinstance(mapper.local_table, expression.TableClause): + return None + if start and not mapper.single: + allconds.append(mapper.inherit_condition) + tables.add(mapper.local_table) + + # only the bottom table needs its criteria to be altered to fit + # the primary key ident - the rest of the tables upwards to the + # descendant-most class should all be present and joined to each + # other. try: - start = False - for mapper in reversed(list(self.iterate_to_root())): - if mapper.local_table in tables: - start = True - elif not isinstance( - mapper.local_table, expression.TableClause - ): - return None - if start and not mapper.single: - allconds.append( - visitors.cloned_traverse( - mapper.inherit_condition, - {}, - {"binary": visit_binary}, - ) - ) + allconds[0] = visitors.cloned_traverse( + allconds[0], {}, {"binary": visit_binary} + ) except _OptGetColumnsNotAvailable: return None |
