summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-02-14 12:51:53 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-02-14 12:51:53 -0500
commit0cee3f6cf09d8f5c20e3f508685204bcf257e074 (patch)
treee21709c2f24ad507f5665dd48c20657c0585db25 /lib/sqlalchemy
parent6458094024107e81eb7c9be140a1a385d26071a6 (diff)
downloadsqlalchemy-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')
-rwxr-xr-xlib/sqlalchemy/ext/declarative.py10
-rw-r--r--lib/sqlalchemy/orm/descriptor_props.py4
2 files changed, 10 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_:
diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py
index 49f310787..d8a4bc8cf 100644
--- a/lib/sqlalchemy/orm/descriptor_props.py
+++ b/lib/sqlalchemy/orm/descriptor_props.py
@@ -164,6 +164,10 @@ class CompositeProperty(DescriptorProperty):
prop = attr.property
props.append(prop)
+ @property
+ def columns(self):
+ return [a for a in self.attrs if isinstance(a, schema.Column)]
+
def _setup_arguments_on_columns(self):
"""Propagate configuration arguments made on this composite
to the target columns, for those that apply.