From 9df4651fba6d1cd3d2b490f58263cc45a81788f4 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 8 Oct 2013 19:47:13 -0400 Subject: Fixed bug where using an annotation such as :func:`.remote` or :func:`.foreign` on a :class:`.Column` before association with a parent :class:`.Table` could produce issues related to the parent table not rendering within joins, due to the inherent copy operation performed by an annotation. [ticket:2813] --- lib/sqlalchemy/sql/elements.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 73a8a0b82..2688ef103 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -2466,7 +2466,7 @@ class AnnotatedColumnElement(Annotated): def __init__(self, element, values): Annotated.__init__(self, element, values) ColumnElement.comparator._reset(self) - for attr in ('name', 'key'): + for attr in ('name', 'key', 'table'): if self.__dict__.get(attr, False) is None: self.__dict__.pop(attr) @@ -2480,6 +2480,11 @@ class AnnotatedColumnElement(Annotated): """pull 'name' from parent, if not present""" return self._Annotated__element.name + @util.memoized_property + def table(self): + """pull 'table' from parent, if not present""" + return self._Annotated__element.table + @util.memoized_property def key(self): """pull 'key' from parent, if not present""" -- cgit v1.2.1