From a31979937223c68f395ee0704593c9150f10e86b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 20 Jan 2007 12:31:27 +0000 Subject: - tightened down conditions used to locate "relation direction", associating the "foreignkey" of the relationship with the "primaryjoin". the column match now must be exact, not just "corresponding". this enables self-referential relationships on a polymorphic mapper. - a little bit of improvement to the concept of a "concrete" inheritance mapping, though that concept is not well fleshed out yet (added test case to support concrete mappers on top of a polymorphic base). --- lib/sqlalchemy/sql.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql.py') diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index f944b468d..5b960546e 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -728,9 +728,17 @@ class FromClause(Selectable): if not hasattr(self, '_oid_column'): self._oid_column = self._locate_oid_column() return self._oid_column - def corresponding_column(self, column, raiseerr=True, keys_ok=False): + def corresponding_column(self, column, raiseerr=True, keys_ok=False, require_exact=False): """given a ColumnElement, return the ColumnElement object from this Selectable which corresponds to that original Column via a proxy relationship.""" + if require_exact: + if self.columns.get(column.key) is column: + return column + else: + if not raiseerr: + return None + else: + raise exceptions.InvalidRequestError("Column instance '%s' is not directly present in table '%s'" % (str(column), str(column.table))) for c in column.orig_set: try: return self.original_columns[c] -- cgit v1.2.1