From: Mike Bayer Date: Sun, 22 Oct 2006 00:42:43 +0000 (+0000) Subject: added __getattr__() proxy to TypeDecorator X-Git-Tag: rel_0_3_0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45b6c7d7784a0a5df645098ba495459d2904a1ae;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git added __getattr__() proxy to TypeDecorator --- diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 1a30bc5cd5..01c2d18f0b 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -86,6 +86,9 @@ class TypeDecorator(AbstractType): tt.impl = typedesc self.impl_dict[dialect] = tt return tt + def __getattr__(self, key): + """proxy all other undefined accessors to the underlying implementation.""" + return getattr(self.impl, key) def get_col_spec(self): return self.impl.get_col_spec() def convert_bind_param(self, value, dialect): diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index db5b2c045d..e438b03fb9 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -136,6 +136,7 @@ class UnicodeTest(AssertMixin): def tearDownAll(self): unicode_table.drop() def testbasic(self): + assert unicode_table.c.unicode_data.type.length == 250 rawdata = 'Alors vous imaginez ma surprise, au lever du jour, quand une dr\xc3\xb4le de petit voix m\xe2\x80\x99a r\xc3\xa9veill\xc3\xa9. Elle disait: \xc2\xab S\xe2\x80\x99il vous pla\xc3\xaet\xe2\x80\xa6 dessine-moi un mouton! \xc2\xbb\n' unicodedata = rawdata.decode('utf-8') unicode_table.insert().execute(unicode_data=unicodedata, plain_data=rawdata)