[Sqlalchemy-commits] [1066] sqlalchemy/trunk/test: oid inits at compilation time/when needed again,
Brought to you by:
zzzeek
From: <co...@sq...> - 2006-02-28 23:18:53
|
<!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>[1066] sqlalchemy/trunk/test: oid inits at compilation time/when needed again, added a unit test</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1066</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-02-28 17:18:43 -0600 (Tue, 28 Feb 2006)</dd> </dl> <h3>Log Message</h3> <pre>oid inits at compilation time/when needed again, added a unit test</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunklibsqlalchemyextproxypy">sqlalchemy/trunk/lib/sqlalchemy/ext/proxy.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemysqlpy">sqlalchemy/trunk/lib/sqlalchemy/sql.py</a></li> <li><a href="#sqlalchemytrunktestproxy_enginepy">sqlalchemy/trunk/test/proxy_engine.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunklibsqlalchemyextproxypy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/ext/proxy.py (1065 => 1066)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/ext/proxy.py 2006-02-28 22:50:43 UTC (rev 1065) +++ sqlalchemy/trunk/lib/sqlalchemy/ext/proxy.py 2006-02-28 23:18:43 UTC (rev 1066) </span><span class="lines">@@ -28,10 +28,8 @@ </span><span class="cx"> return "%s(%s)" % (self.__class__.__name__, id(self)) </span><span class="cx"> </span><span class="cx"> def oid_column_name(self): </span><del>- # NOTE: setting up mappers fails unless the proxy engine returns - # something for oid column name, and the call happens too early - # to proxy, so effecticely no oids are allowed when using - # proxy engine </del><ins>+ # oid_column should not be requested before the engine is connected. + # it should ideally only be called at query compilation time. </ins><span class="cx"> e= self.get_engine() </span><span class="cx"> if e is None: </span><span class="cx"> return None </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemysqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/sql.py (1065 => 1066)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/sql.py 2006-02-28 22:50:43 UTC (rev 1065) +++ sqlalchemy/trunk/lib/sqlalchemy/sql.py 2006-02-28 23:18:43 UTC (rev 1066) </span><span class="lines">@@ -827,7 +827,9 @@ </span><span class="cx"> else: </span><span class="cx"> self.onclause = onclause </span><span class="cx"> self.isouter = isouter </span><del>- self.oid_column = self.left.oid_column </del><ins>+ + oid_column = property(lambda s:s.left.oid_column) + </ins><span class="cx"> def _exportable_columns(self): </span><span class="cx"> return [c for c in self.left.columns] + [c for c in self.right.columns] </span><span class="cx"> def _proxy_column(self, column): </span><span class="lines">@@ -1001,6 +1003,7 @@ </span><span class="cx"> if self.engine.oid_column_name() is not None: </span><span class="cx"> self._oid_column = schema.Column(self.engine.oid_column_name(), sqltypes.Integer, hidden=True) </span><span class="cx"> self._oid_column._set_parent(self) </span><ins>+ self._orig_columns()[self._oid_column.original] = self._oid_column </ins><span class="cx"> else: </span><span class="cx"> self._oid_column = None </span><span class="cx"> return self._oid_column </span><span class="lines">@@ -1011,9 +1014,6 @@ </span><span class="cx"> self._orig_cols= {} </span><span class="cx"> for c in self.columns: </span><span class="cx"> self._orig_cols[c.original] = c </span><del>- oid = self.oid_column - if oid is not None: - self._orig_cols[oid.original] = oid </del><span class="cx"> return self._orig_cols </span><span class="cx"> columns = property(lambda s:s._columns) </span><span class="cx"> c = property(lambda s:s._columns) </span></span></pre></div> <a id="sqlalchemytrunktestproxy_enginepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/proxy_engine.py (1065 => 1066)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/proxy_engine.py 2006-02-28 22:50:43 UTC (rev 1065) +++ sqlalchemy/trunk/test/proxy_engine.py 2006-02-28 23:18:43 UTC (rev 1066) </span><span class="lines">@@ -22,6 +22,17 @@ </span><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> </span><ins>+class ConstructTest(PersistTest): + """tests that we can build SQL constructs without engine-specific parameters, particulary + oid_column, being needed, as the proxy engine is usually not connected yet.""" + def test_join(self): + engine = ProxyEngine() + t = Table('table1', engine, + Column('col1', Integer, primary_key=True)) + t2 = Table('table2', engine, + Column('col2', Integer, ForeignKey('table1.col1'))) + j = join(t, t2) + </ins><span class="cx"> class ProxyEngineTest1(PersistTest): </span><span class="cx"> </span><span class="cx"> def setUp(self): </span></span></pre> </div> </div> </body> </html> |