diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-02-14 12:51:53 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-02-14 12:51:53 -0500 |
commit | 0cee3f6cf09d8f5c20e3f508685204bcf257e074 (patch) | |
tree | e21709c2f24ad507f5665dd48c20657c0585db25 /lib/sqlalchemy/ext/declarative.py | |
parent | 6458094024107e81eb7c9be140a1a385d26071a6 (diff) | |
download | sqlalchemy-0cee3f6cf09d8f5c20e3f508685204bcf257e074.tar.gz |
- Fixed regression whereby composite() with
Column objects placed inline would fail
to initialize. The Column objects can now
be inline with the composite() or external
and pulled in via name or object ref.
[ticket:2058]
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-x | lib/sqlalchemy/ext/declarative.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index f80562b32..00c4aec3f 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -977,16 +977,17 @@ def _as_declarative(cls, classname, dict_): our_stuff.sort(key=lambda key: our_stuff[key]._creation_order) # extract columns from the class dict - cols = [] + cols = set() for key, c in our_stuff.iteritems(): if isinstance(c, (ColumnProperty, CompositeProperty)): for col in c.columns: - if isinstance(col, Column) and col.table is None: + if isinstance(col, Column) and \ + col.table is None: _undefer_column_name(key, col) - cols.append(col) + cols.add(col) elif isinstance(c, Column): _undefer_column_name(key, c) - cols.append(c) + cols.add(c) # if the column is the same name as the key, # remove it from the explicit properties dict. # the normal rules for assigning column-based properties @@ -994,6 +995,7 @@ def _as_declarative(cls, classname, dict_): # in multi-column ColumnProperties. if key == c.key: del our_stuff[key] + cols = sorted(cols, key=lambda c:c._creation_order) table = None if '__table__' not in dict_: |