From: Mike Bayer Date: Mon, 14 Jun 2010 23:39:26 +0000 (-0400) Subject: - Modified the internals of "column annotation" such that X-Git-Tag: rel_0_6_2~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33f6dcc80b43e499562991d7bfaf4f896d55f445;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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. --- diff --git a/CHANGES b/CHANGES index 714f82bab1..94e4961c5c 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 14ea42d2c7..d0af0a9d6e 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 13f629e288..2537c48965 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"))