[Sqlalchemy-commits] [1334] sqlalchemy/trunk/test: removed a "swap" from the lazy binary clause.
Brought to you by:
zzzeek
From: <co...@sq...> - 2006-04-24 22:11:26
|
<!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><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 { 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; } #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>[1334] sqlalchemy/trunk/test: removed a "swap" from the lazy binary clause.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1334</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-04-24 17:11:13 -0500 (Mon, 24 Apr 2006)</dd> </dl> <h3>Log Message</h3> <pre>removed a "swap" from the lazy binary clause. added a test for that condition....</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunklibsqlalchemymappingpropertiespy">sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py</a></li> <li><a href="#sqlalchemytrunktestlazytest1py">sqlalchemy/trunk/test/lazytest1.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunklibsqlalchemymappingpropertiespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py (1333 => 1334)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py 2006-04-24 19:31:23 UTC (rev 1333) +++ sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py 2006-04-24 22:11:13 UTC (rev 1334) </span><span class="lines">@@ -660,7 +660,7 @@ </span><span class="cx"> binary.left = binds.setdefault(binary.left, </span><span class="cx"> sql.BindParamClause(bind_label(), None, shortname = binary.left.name)) </span><span class="cx"> reverselookup[binary.right] = binds[col] </span><del>- binary.swap() </del><ins>+ #binary.swap() </ins><span class="cx"> </span><span class="cx"> if isinstance(binary.right, schema.Column) and isinstance(binary.left, schema.Column) and ((not circular and binary.right.table is table) or (circular and binary.left is foreignkey)): </span><span class="cx"> col = binary.right </span><span class="lines">@@ -671,7 +671,7 @@ </span><span class="cx"> lazywhere = primaryjoin.copy_container() </span><span class="cx"> li = BinaryVisitor(visit_binary) </span><span class="cx"> lazywhere.accept_visitor(li) </span><del>- #print "PRIMARYJOIN", str(lazywhere), [b.key for b in binds.values()] </del><ins>+ print "PRIMARYJOIN", str(lazywhere), [b.key for b in binds.values()] </ins><span class="cx"> if secondaryjoin is not None: </span><span class="cx"> lazywhere = sql.and_(lazywhere, secondaryjoin) </span><span class="cx"> return (lazywhere, binds, reverselookup) </span></span></pre></div> <a id="sqlalchemytrunktestlazytest1py"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/lazytest1.py (1333 => 1334)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/lazytest1.py 2006-04-24 19:31:23 UTC (rev 1333) +++ sqlalchemy/trunk/test/lazytest1.py 2006-04-24 22:11:13 UTC (rev 1334) </span><span class="lines">@@ -56,6 +56,9 @@ </span><span class="cx"> rel_table.drop() </span><span class="cx"> info_table.drop() </span><span class="cx"> </span><ins>+ def setUp(self): + clear_mappers() + </ins><span class="cx"> def testone(self): </span><span class="cx"> """tests a lazy load which has multiple join conditions, including two that are against </span><span class="cx"> the same column in the child table""" </span><span class="lines">@@ -76,7 +79,8 @@ </span><span class="cx"> Relation.mapper.add_property('datas', relation(Data.mapper, </span><span class="cx"> primaryjoin=and_(Relation.c.info_pk==Data.c.info_pk, </span><span class="cx"> Data.c.timeval >= Relation.c.start, </span><del>- Data.c.timeval <= Relation.c.finish), </del><ins>+ Data.c.timeval <= Relation.c.finish + ), </ins><span class="cx"> foreignkey=Data.c.info_pk)) </span><span class="cx"> </span><span class="cx"> Information.mapper.add_property('rels', relation(Relation.mapper)) </span><span class="lines">@@ -86,6 +90,39 @@ </span><span class="cx"> assert len(info.rels) == 2 </span><span class="cx"> assert len(info.rels[0].datas) == 3 </span><span class="cx"> </span><ins>+ def testtwo(self): + """same thing, but reversing the order of the cols in the join""" + class Information(object): + pass + + class Relation(object): + pass + + class Data(object): + pass + + # Create the basic mappers, with no frills or modifications + Information.mapper = mapper(Information, info_table) + Data.mapper = mapper(Data, data_table) + Relation.mapper = mapper(Relation, rel_table) + + Relation.mapper.add_property('datas', relation(Data.mapper, + primaryjoin=and_(Relation.c.info_pk==Data.c.info_pk, + Relation.c.start <= Data.c.timeval, + Relation.c.finish >= Data.c.timeval, + # Data.c.timeval >= Relation.c.start, + # Data.c.timeval <= Relation.c.finish + ), + foreignkey=Data.c.info_pk)) + + Information.mapper.add_property('rels', relation(Relation.mapper)) + + info = Information.mapper.get(1) + assert info + assert len(info.rels) == 2 + assert len(info.rels[0].datas) == 3 + + </ins><span class="cx"> if __name__ == "__main__": </span><span class="cx"> testbase.main() </span><span class="cx"> </span></span></pre> </div> </div> </body> </html> |