diff options
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/schema.py | 7 | ||||
-rw-r--r-- | test/ext/declarative.py | 2 |
3 files changed, 14 insertions, 1 deletions
@@ -13,11 +13,17 @@ CHANGES Set collection is now compatible with merge(), fixes [ticket:1352]. +- sql + - Fixed __repr__() and other _get_colspec() methods on + ForeignKey constructed from __clause_element__() style + construct (i.e. declarative columns). [ticket:1353] + - mssql - Corrected problem with information schema not working with a binary collation based database. Cleaned up information schema since it is only used by mssql now. [ticket:1343] +>>>>>>> .r5862 0.5.3 ===== - orm diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index c4f9a2895..fd99d2de7 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -842,8 +842,13 @@ class ForeignKey(SchemaItem): return schema + "." + self.column.table.name + "." + self.column.key elif isinstance(self._colspec, basestring): return self._colspec + elif hasattr(self._colspec, '__clause_element__'): + _column = self._colspec.__clause_element__() else: - return "%s.%s" % (self._colspec.table.fullname, self._colspec.key) + _column = self._colspec + + return "%s.%s" % (_column.table.fullname, _column.key) + target_fullname = property(_get_colspec) def references(self, table): diff --git a/test/ext/declarative.py b/test/ext/declarative.py index 738f37495..c6d4fe681 100644 --- a/test/ext/declarative.py +++ b/test/ext/declarative.py @@ -675,6 +675,8 @@ class DeclarativeTest(DeclarativeTestBase): # longer the case sa.orm.compile_mappers() + eq_(str(Address.user_id.property.columns[0].foreign_keys[0]), "ForeignKey('users.id')") + Base.metadata.create_all() u1 = User(name='u1', addresses=[ Address(email='one'), |