[Sqlalchemy-commits] [1232] sqlalchemy/trunk/test: added for_update flag to Select/CompoundSelect
Brought to you by:
zzzeek
From: <co...@sq...> - 2006-03-31 22:28:30
|
<!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>[1232] sqlalchemy/trunk/test: added for_update flag to Select/CompoundSelect</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1232</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-03-31 16:28:17 -0600 (Fri, 31 Mar 2006)</dd> </dl> <h3>Log Message</h3> <pre>added for_update flag to Select/CompoundSelect</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunklibsqlalchemyansisqlpy">sqlalchemy/trunk/lib/sqlalchemy/ansisql.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemysqlpy">sqlalchemy/trunk/lib/sqlalchemy/sql.py</a></li> <li><a href="#sqlalchemytrunktestselectpy">sqlalchemy/trunk/test/select.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunklibsqlalchemyansisqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/ansisql.py (1231 => 1232)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/ansisql.py 2006-03-31 07:36:51 UTC (rev 1231) +++ sqlalchemy/trunk/lib/sqlalchemy/ansisql.py 2006-03-31 22:28:17 UTC (rev 1232) </span><span class="lines">@@ -373,6 +373,9 @@ </span><span class="cx"> </span><span class="cx"> text += self.visit_select_postclauses(select) </span><span class="cx"> </span><ins>+ if select.for_update: + text += " FOR UPDATE" + </ins><span class="cx"> if getattr(select, 'parens', False): </span><span class="cx"> self.strings[select] = "(" + text + ")" </span><span class="cx"> else: </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemysqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/sql.py (1231 => 1232)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/sql.py 2006-03-31 07:36:51 UTC (rev 1231) +++ sqlalchemy/trunk/lib/sqlalchemy/sql.py 2006-03-31 22:28:17 UTC (rev 1232) </span><span class="lines">@@ -1176,6 +1176,7 @@ </span><span class="cx"> self.use_labels = kwargs.pop('use_labels', False) </span><span class="cx"> self.parens = kwargs.pop('parens', False) </span><span class="cx"> self.correlate = kwargs.pop('correlate', False) </span><ins>+ self.for_update = kwargs.pop('for_update', False) </ins><span class="cx"> self.oid_column = selects[0].oid_column </span><span class="cx"> for s in self.selects: </span><span class="cx"> s.group_by(None) </span><span class="lines">@@ -1211,7 +1212,7 @@ </span><span class="cx"> class Select(SelectBaseMixin, FromClause): </span><span class="cx"> """represents a SELECT statement, with appendable clauses, as well as </span><span class="cx"> the ability to execute itself and return a result set.""" </span><del>- def __init__(self, columns=None, whereclause = None, from_obj = [], order_by = None, group_by=None, having=None, use_labels = False, distinct=False, engine = None, limit=None, offset=None, scalar=False, correlate=True): </del><ins>+ def __init__(self, columns=None, whereclause = None, from_obj = [], order_by = None, group_by=None, having=None, use_labels = False, distinct=False, for_update=False, engine=None, limit=None, offset=None, scalar=False, correlate=True): </ins><span class="cx"> self._froms = util.OrderedDict() </span><span class="cx"> self.use_labels = use_labels </span><span class="cx"> self.name = None </span><span class="lines">@@ -1221,6 +1222,7 @@ </span><span class="cx"> self.oid_column = None </span><span class="cx"> self.limit = limit </span><span class="cx"> self.offset = offset </span><ins>+ self.for_update = for_update </ins><span class="cx"> </span><span class="cx"> # indicates that this select statement should not expand its columns </span><span class="cx"> # into the column clause of an enclosing select, and should instead </span></span></pre></div> <a id="sqlalchemytrunktestselectpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/select.py (1231 => 1232)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/select.py 2006-03-31 07:36:51 UTC (rev 1231) +++ sqlalchemy/trunk/test/select.py 2006-03-31 22:28:17 UTC (rev 1232) </span><span class="lines">@@ -240,6 +240,11 @@ </span><span class="cx"> select([table2.c.othername, func.count(table2.c.otherid)], group_by = [table2.c.othername], order_by = [table2.c.othername]), </span><span class="cx"> "SELECT myothertable.othername, count(myothertable.otherid) FROM myothertable GROUP BY myothertable.othername ORDER BY myothertable.othername" </span><span class="cx"> ) </span><ins>+ + def testforupdate(self): + self.runtest( + table1.select(table1.c.myid==7, for_update=True), "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid = :mytable_myid FOR UPDATE" + ) </ins><span class="cx"> def testalias(self): </span><span class="cx"> # test the alias for a table1. column names stay the same, table name "changes" to "foo". </span><span class="cx"> self.runtest( </span></span></pre> </div> </div> </body> </html> |