]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed __repr__() and other _get_colspec() methods on
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 27 Mar 2009 21:41:36 +0000 (21:41 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 27 Mar 2009 21:41:36 +0000 (21:41 +0000)
ForeignKey constructed from __clause_element__() style
construct (i.e. declarative columns).  [ticket:1353]

CHANGES
lib/sqlalchemy/schema.py
test/ext/declarative.py

diff --git a/CHANGES b/CHANGES
index ba3bf243d5a6b269575b18967e9e0f8b5f5833c9..2ef7414b24b34331b964e89e676397555bb70895 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index c4f9a2895647e66904632aa5432feb940ae8b115..fd99d2de70390c03c39a67a82254f3bf9ac6eaab 100644 (file)
@@ -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):
index 738f37495582a6bd1b63ea9dc8586d656cafe456..c6d4fe681471c642f0064ad074335acd2c2e13b5 100644 (file)
@@ -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'),