]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
if type is None it will be propigated from a ForeignKey
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Oct 2006 18:29:25 +0000 (18:29 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Oct 2006 18:29:25 +0000 (18:29 +0000)
lib/sqlalchemy/schema.py

index dd11f6e806c9249ccba37ed5a11455420ea467fd..efbc15d2425d1663b011427f31fe0c2933ed251b 100644 (file)
@@ -311,11 +311,11 @@ class Column(SchemaItem, sql._ColumnClause):
         name : the name of this column.  this should be the identical name as it appears,
         or will appear, in the database.
         
-        type : this is the type of column. This can be any subclass of types.TypeEngine,
-        including the database-agnostic types defined in the types module, database-specific types
-        defined within specific database modules, or user-defined types.
+        type: the TypeEngine for this column.
+        This can be any subclass of types.AbstractType, including the database-agnostic types defined 
+        in the types module, database-specific types defined within specific database modules, or user-defined types.
         
-        *args : ForeignKey and Sequence objects should be added as list values.
+        *args: Constraint, ForeignKey, ColumnDefault and Sequence objects should be added as list values.
         
         **kwargs : keyword arguments include:
         
@@ -364,7 +364,7 @@ class Column(SchemaItem, sql._ColumnClause):
         case_sensitive=True : indicates that the identifier should be interpreted by the database in the natural case for identifiers.
         Mixed case is not sufficient to cause this identifier to be quoted; it must contain an illegal character.
         """
-        name = str(name) # in case of incoming unicode
+        name = str(name) # in case of incoming unicode        
         super(Column, self).__init__(name, None, type)
         self.args = args
         self.key = kwargs.pop('key', name)
@@ -561,7 +561,9 @@ class ForeignKey(SchemaItem):
                     raise exceptions.ArgumentError("Could not create ForeignKey '%s' on table '%s': table '%s' has no column named '%s'" % (self._colspec, parenttable.name, table.name, e.args[0]))
             else:
                 self._column = self._colspec
-
+        # propigate TypeEngine to parent if it didnt have one
+        if self.parent.type is types.NULLTYPE:
+            self.parent.type = self._column.type
         return self._column
             
     column = property(lambda s: s._init_column())