summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-02-28 12:47:04 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-02-28 12:47:04 -0500
commitcf5113115047032dd46724d1e3f56dfca6503eee (patch)
tree8039f3b00af76df71f2239fe20801a54dbd04402 /lib/sqlalchemy/schema.py
parenta7f766d7c7fd6c53eb0019e32569e915b3f31eb4 (diff)
downloadsqlalchemy-cf5113115047032dd46724d1e3f56dfca6503eee.tar.gz
- Added a fully descriptive error message for the
case where Column is subclassed and _make_proxy() fails to make a copy due to TypeError on the constructor. The method _constructor should be implemented in this case.
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r--lib/sqlalchemy/schema.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index 80d6018b8..223643c80 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -904,13 +904,32 @@ class Column(SchemaItem, expression.ColumnClause):
raise exc.InvalidRequestError("Cannot initialize a sub-selectable"
" with this Column object until it's 'name' has "
"been assigned.")
- c = self._constructor(
- name or self.name,
- self.type,
- key = name or self.key,
- primary_key = self.primary_key,
- nullable = self.nullable,
- quote=self.quote, _proxies=[self], *fk)
+ try:
+ c = self._constructor(
+ name or self.name,
+ self.type,
+ key = name or self.key,
+ primary_key = self.primary_key,
+ nullable = self.nullable,
+ quote=self.quote, _proxies=[self], *fk)
+ except TypeError, e:
+ # Py3K
+ #raise TypeError(
+ # "Could not create a copy of this %r object. "
+ # "Ensure the class includes a _constructor() "
+ # "attribute or method which accepts the "
+ # "standard Column constructor arguments, or "
+ # "references the Column class itself." % self.__class__) from e
+ # Py2K
+ raise TypeError(
+ "Could not create a copy of this %r object. "
+ "Ensure the class includes a _constructor() "
+ "attribute or method which accepts the "
+ "standard Column constructor arguments, or "
+ "references the Column class itself. "
+ "Original error: %s" % (self.__class__, e))
+ # end Py2K
+
c.table = selectable
selectable._columns.add(c)
if self.primary_key: