summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-07-13 07:36:39 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-07-13 07:36:39 +0000
commitde220677418653257b0068c71e87698e8978796b (patch)
tree3c5d19de610252e59e9c5734395d4e6cb789f568 /lib/sqlalchemy/sql.py
parent94d81c84cefee51485c26d79b028aa85e61b147c (diff)
downloadsqlalchemy-de220677418653257b0068c71e87698e8978796b.tar.gz
- composite primary key is represented as a non-keyed set to allow for
composite keys consisting of cols with the same name; occurs within a Join. helps inheritance scenarios formulate correct PK. - ticket #185 reopened. still need to get Join to produce a minmal PK for fk'ed columns
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r--lib/sqlalchemy/sql.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index ff6aa5e2c..d1fc3fef1 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -1618,6 +1618,25 @@ class ColumnCollection(util.OrderedProperties):
# "True" value (i.e. a BinaryClause...)
return col in util.Set(self)
+class ColumnSet(util.OrderedSet):
+ def contains_column(self, col):
+ return col in self
+
+ def extend(self, cols):
+ for col in cols:
+ self.add(col)
+
+ def __add__(self, other):
+ return list(self) + list(other)
+
+ def __eq__(self, other):
+ l = []
+ for c in other:
+ for local in self:
+ if c.shares_lineage(local):
+ l.append(c==local)
+ return and_(*l)
+
class FromClause(Selectable):
"""Represent an element that can be used within the ``FROM``
clause of a ``SELECT`` statement.
@@ -1762,7 +1781,7 @@ class FromClause(Selectable):
# TODO: put a mutex here ? this is a key place for threading probs
return
self._columns = ColumnCollection()
- self._primary_key = ColumnCollection()
+ self._primary_key = ColumnSet()
self._foreign_keys = util.Set()
self._orig_cols = {}
for co in self._adjusted_exportable_columns():