summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-03-18 03:07:54 +0000
committerJason Kirtland <jek@discorporate.us>2008-03-18 03:07:54 +0000
commit031c500ff4c69bb43914cda707796f15e6b132c2 (patch)
treefc079a622104637aa9c44e0f21141c11d8f4227c /lib
parent67fc7abe6d85bb1f6b500b47cb507082b97365d7 (diff)
downloadsqlalchemy-031c500ff4c69bb43914cda707796f15e6b132c2.tar.gz
- Column._set_parent will complete the key==name contract for instances constructed anonymously
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/schema.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index c3db8bfad..a393c160f 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -412,7 +412,9 @@ class Column(SchemaItem, expression._ColumnClause):
name
The name of this column. This should be the identical name as it
- appears, or will appear, in the database.
+ appears, or will appear, in the database. Name may be omitted at
+ construction time but must be assigned before adding a Column
+ instance to a Table.
type\_
The ``TypeEngine`` for this column. This can be any subclass of
@@ -430,8 +432,10 @@ class Column(SchemaItem, expression._ColumnClause):
Keyword arguments include:
key
- Defaults to None: an optional *alias name* for this column. The
- column will then be identified everywhere in an application,
+ Defaults to the column name: a Python-only *alias name* for this
+ column.
+
+ The column will then be identified everywhere in an application,
including the column list on its Table, by this key, and not the
given name. Generated SQL, however, will still reference the
column by its actual name.
@@ -583,6 +587,8 @@ class Column(SchemaItem, expression._ColumnClause):
raise exceptions.ArgumentError(
"Column must be constructed with a name or assign .name "
"before adding to a Table.")
+ if self.key is None:
+ self.key = self.name
self.metadata = table.metadata
if getattr(self, 'table', None) is not None:
raise exceptions.ArgumentError("this Column already has a table!")