summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-12-10 04:31:17 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-12-10 04:31:17 +0000
commit41df778985ce5b99935ff4b1ffa0c7249a03a83a (patch)
tree7454bada25153ba8091ee6df0a08b1307dbd609b /lib/sqlalchemy/schema.py
parent5cdb942791b9aeb63d02680c712d1afc104606b0 (diff)
downloadsqlalchemy-41df778985ce5b99935ff4b1ffa0c7249a03a83a.tar.gz
- more query tests
- trying to refine some of the adaptation stuff - query.from_statement() wont allow further generative criterion - added a warning to columncollection when selectable is formed with conflicting columns (only in the col export phase) - some method rearrangement on schema/columncollection.... - property conflicting relation warning doesnt raise for concrete
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r--lib/sqlalchemy/schema.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index 817981003..15b35b96a 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -493,6 +493,7 @@ class Column(SchemaItem, expression._ColumnClause):
[repr(self.name)] + [repr(self.type)] +
[repr(x) for x in self.foreign_keys if x is not None] +
[repr(x) for x in self.constraints] +
+ [(self.table and "table=<%s>" % self.table.description or "")] +
["%s=%s" % (k, repr(getattr(self, k))) for k in kwarg])
def _get_parent(self):
@@ -504,12 +505,13 @@ class Column(SchemaItem, expression._ColumnClause):
raise exceptions.ArgumentError("this Column already has a table!")
if not self._is_oid:
self._pre_existing_column = table._columns.get(self.key)
- table._columns.add(self)
+
+ table._columns.replace(self)
else:
self._pre_existing_column = None
if self.primary_key:
- table.primary_key.add(self)
+ table.primary_key.replace(self)
elif self.key in table.primary_key:
raise exceptions.ArgumentError("Trying to redefine primary-key column '%s' as a non-primary-key column on table '%s'" % (self.key, table.fullname))
# if we think this should not raise an error, we'd instead do this:
@@ -899,19 +901,20 @@ class PrimaryKeyConstraint(Constraint):
self.table = table
table.primary_key = self
for c in self.__colnames:
- self.append_column(table.c[c])
-
+ self.add(table.c[c])
+
def add(self, col):
- self.append_column(col)
+ self.columns.add(col)
+ col.primary_key=True
+ append_column = add
+
+ def replace(self, col):
+ self.columns.replace(col)
def remove(self, col):
col.primary_key=False
del self.columns[col.key]
- def append_column(self, col):
- self.columns.add(col)
- col.primary_key=True
-
def copy(self):
return PrimaryKeyConstraint(name=self.name, *[c.key for c in self])