From 45b6c7d7784a0a5df645098ba495459d2904a1ae Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 22 Oct 2006 00:42:43 +0000 Subject: [PATCH] added __getattr__() proxy to TypeDecorator --- lib/sqlalchemy/types.py | 3 +++ test/sql/testtypes.py | 1 + 2 files changed, 4 insertions(+) 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) -- 2.47.2