[Sqlalchemy-commits] [3985] sqlalchemy/trunk: fix to new TypeDecorator
Brought to you by:
zzzeek
From: <co...@sq...> - 2008-01-01 01:48:05
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[3985] sqlalchemy/trunk: fix to new TypeDecorator</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>3985</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2007-12-31 20:47:58 -0500 (Mon, 31 Dec 2007)</dd> </dl> <h3>Log Message</h3> <pre>fix to new TypeDecorator</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunklibsqlalchemytypespy">sqlalchemy/trunk/lib/sqlalchemy/types.py</a></li> <li><a href="#sqlalchemytrunktestsqltesttypespy">sqlalchemy/trunk/test/sql/testtypes.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunklibsqlalchemytypespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/types.py (3984 => 3985)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/types.py 2008-01-01 00:43:24 UTC (rev 3984) +++ sqlalchemy/trunk/lib/sqlalchemy/types.py 2008-01-01 01:47:58 UTC (rev 3985) </span><span class="lines">@@ -246,7 +246,9 @@ </span><span class="cx"> return impl_processor(self.process_bind_param(value, dialect)) </span><span class="cx"> return process </span><span class="cx"> else: </span><del>- return self.process_bind_param </del><ins>+ def process(value): + return self.process_bind_param(value, dialect) + return process </ins><span class="cx"> else: </span><span class="cx"> return self.impl.bind_processor(dialect) </span><span class="cx"> </span><span class="lines">@@ -258,7 +260,9 @@ </span><span class="cx"> return self.process_result_value(impl_processor(value), dialect) </span><span class="cx"> return process </span><span class="cx"> else: </span><del>- return self.process_result_value </del><ins>+ def process(value): + return self.process_result_value(value, dialect) + return process </ins><span class="cx"> else: </span><span class="cx"> return self.impl.result_processor(dialect) </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunktestsqltesttypespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/sql/testtypes.py (3984 => 3985)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/sql/testtypes.py 2008-01-01 00:43:24 UTC (rev 3984) +++ sqlalchemy/trunk/test/sql/testtypes.py 2008-01-01 01:47:58 UTC (rev 3985) </span><span class="lines">@@ -50,6 +50,18 @@ </span><span class="cx"> def copy(self): </span><span class="cx"> return MyNewUnicodeType(self.impl.length) </span><span class="cx"> </span><ins>+class MyNewIntType(types.TypeDecorator): + impl = Integer + + def process_bind_param(self, value, dialect): + return value * 10 + + def process_result_value(self, value, dialect): + return value * 10 + + def copy(self): + return MyNewIntType() + </ins><span class="cx"> class MyUnicodeType(types.TypeDecorator): </span><span class="cx"> impl = Unicode </span><span class="cx"> </span><span class="lines">@@ -203,17 +215,20 @@ </span><span class="cx"> def testprocessing(self): </span><span class="cx"> </span><span class="cx"> global users </span><del>- users.insert().execute(user_id = 2, goofy = 'jack', goofy2='jack', goofy3='jack', goofy4=u'jack', goofy5=u'jack', goofy6='jack', goofy7=u'jack') - users.insert().execute(user_id = 3, goofy = 'lala', goofy2='lala', goofy3='lala', goofy4=u'lala', goofy5=u'lala', goofy6='lala', goofy7=u'lala') - users.insert().execute(user_id = 4, goofy = 'fred', goofy2='fred', goofy3='fred', goofy4=u'fred', goofy5=u'fred', goofy6='fred', goofy7=u'fred') </del><ins>+ users.insert().execute(user_id = 2, goofy = 'jack', goofy2='jack', goofy3='jack', goofy4=u'jack', goofy5=u'jack', goofy6='jack', goofy7=u'jack', goofy8=12) + users.insert().execute(user_id = 3, goofy = 'lala', goofy2='lala', goofy3='lala', goofy4=u'lala', goofy5=u'lala', goofy6='lala', goofy7=u'lala', goofy8=15) + users.insert().execute(user_id = 4, goofy = 'fred', goofy2='fred', goofy3='fred', goofy4=u'fred', goofy5=u'fred', goofy6='fred', goofy7=u'fred', goofy8=9) </ins><span class="cx"> </span><span class="cx"> l = users.select().execute().fetchall() </span><del>- for assertstr, row in zip( </del><ins>+ for assertstr, assertint, row in zip( </ins><span class="cx"> ["BIND_INjackBIND_OUT", "BIND_INlalaBIND_OUT", "BIND_INfredBIND_OUT"], </span><ins>+ [1200, 1500, 900], </ins><span class="cx"> l </span><ins>+ </ins><span class="cx"> ): </span><del>- for col in row[1:]: </del><ins>+ for col in row[1:8]: </ins><span class="cx"> self.assertEquals(col, assertstr) </span><ins>+ self.assertEquals(row[8], assertint) </ins><span class="cx"> for col in (row[4], row[5], row[7]): </span><span class="cx"> assert isinstance(col, unicode) </span><span class="cx"> </span><span class="lines">@@ -235,6 +250,7 @@ </span><span class="cx"> Column('goofy5', LegacyUnicodeType, nullable = False), </span><span class="cx"> Column('goofy6', LegacyType, nullable = False), </span><span class="cx"> Column('goofy7', MyNewUnicodeType, nullable = False), </span><ins>+ Column('goofy8', MyNewIntType, nullable = False), </ins><span class="cx"> </span><span class="cx"> ) </span><span class="cx"> </span></span></pre> </div> </div> </body> </html> |