[Sqlalchemy-commits] [3971] sqlalchemy/trunk: - disabled the "populate expired/ deferred attributes
Brought to you by:
zzzeek
From: <co...@sq...> - 2007-12-21 16:22:58
|
<!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>[3971] sqlalchemy/trunk: - disabled the "populate expired/ deferred attributes as we come across them" functionality in mapper. _instance(), as its not completed, doesn' t properly handle mutable scalar attributes, and has poor test coverage</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>3971</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2007-12-21 11:20:46 -0500 (Fri, 21 Dec 2007)</dd> </dl> <h3>Log Message</h3> <pre>- disabled the "populate expired/deferred attributes as we come across them" functionality in mapper._instance(), as its not completed, doesn't properly handle mutable scalar attributes, and has poor test coverage</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunklibsqlalchemyormmapperpy">sqlalchemy/trunk/lib/sqlalchemy/orm/mapper.py</a></li> <li><a href="#sqlalchemytrunktestormexpirepy">sqlalchemy/trunk/test/orm/expire.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunklibsqlalchemyormmapperpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/orm/mapper.py (3970 => 3971)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/orm/mapper.py 2007-12-21 07:26:39 UTC (rev 3970) +++ sqlalchemy/trunk/lib/sqlalchemy/orm/mapper.py 2007-12-21 16:20:46 UTC (rev 3971) </span><span class="lines">@@ -1366,12 +1366,12 @@ </span><span class="cx"> if 'populate_instance' not in extension.methods or extension.populate_instance(self, context, row, instance, only_load_props=only_load_props, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE: </span><span class="cx"> self.populate_instance(context, instance, row, only_load_props=only_load_props, instancekey=identitykey, isnew=isnew) </span><span class="cx"> </span><del>- elif getattr(state, 'expired_attributes', None): - # TODO: dont base this off of 'expired_attrbutes' - base it off of unloaded attrs, possibly - # based on the state.callables collection. - attrs = state.expired_attributes.intersection(state.unmodified) - if 'populate_instance' not in extension.methods or extension.populate_instance(self, context, row, instance, only_load_props=attrs, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE: - self.populate_instance(context, instance, row, only_load_props=attrs, instancekey=identitykey, isnew=isnew) </del><ins>+# NOTYET: populate attributes on non-loading instances which have been expired, deferred, etc. +# elif getattr(state, 'expired_attributes', None): # TODO: base off total set of unloaded attributes, not just exp +# attrs = state.expired_attributes.intersection(state.unmodified) +# if 'populate_instance' not in extension.methods or extension.populate_instance(self, context, row, instance, only_load_props=attrs, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE: +# self.populate_instance(context, instance, row, only_load_props=attrs, instancekey=identitykey, isnew=isnew) +# context.partials.add((state, attrs)) <-- allow query.instances to commit the subset of attrs </ins><span class="cx"> </span><span class="cx"> if result is not None and ('append_result' not in extension.methods or extension.append_result(self, context, row, instance, result, instancekey=identitykey, isnew=isnew) is EXT_CONTINUE): </span><span class="cx"> result.append(instance) </span><span class="lines">@@ -1412,8 +1412,6 @@ </span><span class="cx"> existing_populators = [] </span><span class="cx"> post_processors = [] </span><span class="cx"> for prop in self.__props.values(): </span><del>- if only_load_props and prop.key not in only_load_props: - continue </del><span class="cx"> (newpop, existingpop, post_proc) = selectcontext.exec_with_path(self, prop.key, prop.create_row_processor, selectcontext, self, row) </span><span class="cx"> if newpop is not None: </span><span class="cx"> new_populators.append((prop.key, newpop)) </span></span></pre></div> <a id="sqlalchemytrunktestormexpirepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/orm/expire.py (3970 => 3971)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/orm/expire.py 2007-12-21 07:26:39 UTC (rev 3970) +++ sqlalchemy/trunk/test/orm/expire.py 2007-12-21 16:20:46 UTC (rev 3971) </span><span class="lines">@@ -38,14 +38,17 @@ </span><span class="cx"> sess.expire(u) </span><span class="cx"> # object isnt refreshed yet, using dict to bypass trigger </span><span class="cx"> assert u.__dict__.get('name') != 'jack' </span><del>- # reload all - sess.query(User).all() - # test that it refreshed - assert u.__dict__['name'] == 'jack' </del><span class="cx"> </span><del>- def go(): - assert u.name == 'jack' - self.assert_sql_count(testbase.db, go, 0) </del><ins>+ if False: + # NOTYET: need to implement unconditional population + # of expired attriutes in mapper._instances() + sess.query(User).all() + # test that it refreshed + assert u.__dict__['name'] == 'jack' + + def go(): + assert u.name == 'jack' + self.assert_sql_count(testbase.db, go, 0) </ins><span class="cx"> </span><span class="cx"> def test_expire_doesntload_on_set(self): </span><span class="cx"> mapper(User, users) </span><span class="lines">@@ -91,12 +94,15 @@ </span><span class="cx"> assert o.isopen == 1 </span><span class="cx"> assert o.description == 'some new description' </span><span class="cx"> </span><del>- sess.expire(o, ['isopen', 'description']) - sess.query(Order).all() - del o.isopen - def go(): - assert o.isopen is None - self.assert_sql_count(testbase.db, go, 0) </del><ins>+ if False: + # NOTYET: need to implement unconditional population + # of expired attriutes in mapper._instances() + sess.expire(o, ['isopen', 'description']) + sess.query(Order).all() + del o.isopen + def go(): + assert o.isopen is None + self.assert_sql_count(testbase.db, go, 0) </ins><span class="cx"> </span><span class="cx"> def test_expire_committed(self): </span><span class="cx"> """test that the committed state of the attribute receives the most recent DB data""" </span></span></pre> </div> </div> </body> </html> |