diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-05 00:59:19 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-05 00:59:19 +0000 |
commit | 0e25c2d9e8539dc45dc34c9cc28c7b42f2e97aac (patch) | |
tree | c0bbd8d5dd0573dbf98ca879f0bb626e172c492d /lib/sqlalchemy/schema.py | |
parent | 303e753b2d674d89f8277e8cd06dd0acf7094549 (diff) | |
download | sqlalchemy-0e25c2d9e8539dc45dc34c9cc28c7b42f2e97aac.tar.gz |
- rewrote and simplified the system used to "target" columns across
selectable expressions. On the SQL side this is represented by the
"corresponding_column()" method. This method is used heavily by the ORM
to "adapt" elements of an expression to similar, aliased expressions,
as well as to target result set columns originally bound to a
table or selectable to an aliased, "corresponding" expression. The new
rewrite features completely consistent and accurate behavior.
- the "orig_set" and "distance" elements as well as all associated
fanfare are gone (hooray !)
- columns now have an optional "proxies" list which is a list of all
columns they are a "proxy" for; only CompoundSelect cols proxy more than one column
(just like before). set operations are used to determine lineage.
- CompoundSelects (i.e. unions) only create one public-facing proxy column per
column name. primary key collections come out with just one column per embedded
PK column.
- made the alias used by eager load limited subquery anonymous.
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r-- | lib/sqlalchemy/schema.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 29a28e54b..5ddca718a 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -449,7 +449,6 @@ class Column(SchemaItem, expression._ColumnClause): self.onupdate = kwargs.pop('onupdate', None) self.autoincrement = kwargs.pop('autoincrement', True) self.constraints = util.Set() - self.__originating_column = self self._foreign_keys = util.OrderedSet() if kwargs: raise exceptions.ArgumentError("Unknown arguments passed to Column: " + repr(kwargs.keys())) @@ -554,9 +553,7 @@ class Column(SchemaItem, expression._ColumnClause): fk = [ForeignKey(f._colspec) for f in self.foreign_keys] c = Column(name or self.name, self.type, self.default, key = name or self.key, primary_key = self.primary_key, nullable = self.nullable, _is_oid = self._is_oid, quote=self.quote, *fk) c.table = selectable - c.orig_set = self.orig_set - c.__originating_column = self.__originating_column - c._distance = self._distance + 1 + c.proxies = [self] c._pre_existing_column = self._pre_existing_column if not c._is_oid: selectable.columns.add(c) @@ -635,10 +632,8 @@ class ForeignKey(SchemaItem): # locate the parent table this foreign key is attached to. # we use the "original" column which our parent column represents # (its a list of columns/other ColumnElements if the parent table is a UNION) - for c in self.parent.orig_set: - if isinstance(c, Column): - parenttable = c.table - break + if isinstance(self.parent.base_column, Column): + parenttable = self.parent.base_column.table else: raise exceptions.ArgumentError("Parent column '%s' does not descend from a table-attached Column" % str(self.parent)) m = re.match(r"^(.+?)(?:\.(.+?))?(?:\.(.+?))?$", self._colspec, re.UNICODE) |