summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-06-14 19:39:26 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-06-14 19:39:26 -0400
commit33f6dcc80b43e499562991d7bfaf4f896d55f445 (patch)
tree075a92c878751ff8576b5713feb1f16c1981270c
parent92599bfec69afa53ea417b183deb2e45eeb91285 (diff)
downloadsqlalchemy-33f6dcc80b43e499562991d7bfaf4f896d55f445.tar.gz
- Modified the internals of "column annotation" such that
a custom Column subclass can safely override _constructor to return Column, for the purposes of making "configurational" column classes that aren't involved in proxying, etc.
-rw-r--r--CHANGES6
-rw-r--r--lib/sqlalchemy/sql/util.py2
-rw-r--r--test/sql/test_selectable.py18
3 files changed, 25 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 714f82bab..94e4961c5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -29,6 +29,12 @@ CHANGES
initialize has been called. the internal name ".conn"
is changed to ".bind", since that's what it is.
+ - Modified the internals of "column annotation" such that
+ a custom Column subclass can safely override
+ _constructor to return Column, for the purposes of
+ making "configurational" column classes that aren't
+ involved in proxying, etc.
+
- firebird
- Fixed incorrect signature in do_execute(), error
introduced in 0.6.1. [ticket:1823]
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index 14ea42d2c..d0af0a9d6 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -273,7 +273,7 @@ class Annotated(object):
@property
def _constructor(self):
- return self.__element.__class__
+ return self.__element._constructor
def _clone(self):
clone = self.__element._clone()
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 13f629e28..2537c4896 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -598,6 +598,24 @@ class DerivedTest(TestBase, AssertsExecutionResults):
assert not t2.select().alias('foo').is_derived_from(t1)
class AnnotationsTest(TestBase):
+ def test_custom_constructions(self):
+ from sqlalchemy.schema import Column
+ class MyColumn(Column):
+ def __init__(self):
+ Column.__init__(self, 'foo', Integer)
+ _constructor = Column
+
+ t1 = Table('t1', MetaData(), MyColumn())
+ s1 = t1.select()
+ assert isinstance(t1.c.foo, MyColumn)
+ assert isinstance(s1.c.foo, Column)
+
+ annot_1 = t1.c.foo._annotate({})
+ s2 = select([annot_1])
+ assert isinstance(s2.c.foo, Column)
+ annot_2 = s1._annotate({})
+ assert isinstance(annot_2.c.foo, Column)
+
def test_annotated_corresponding_column(self):
table1 = table('table1', column("col1"))