[Sqlalchemy-commits] [1428] sqlalchemy/branches/schema/lib/sqlalchemy: assorted cleanuppage
Brought to you by:
zzzeek
From: <co...@sq...> - 2006-05-08 19:01: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>[1428] sqlalchemy/branches/schema/lib/sqlalchemy: assorted cleanuppage</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1428</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-05-08 14:00:51 -0500 (Mon, 08 May 2006)</dd> </dl> <h3>Log Message</h3> <pre>assorted cleanuppage</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemybranchesschemalibsqlalchemyormmapperpy">sqlalchemy/branches/schema/lib/sqlalchemy/orm/mapper.py</a></li> <li><a href="#sqlalchemybranchesschemalibsqlalchemysqlpy">sqlalchemy/branches/schema/lib/sqlalchemy/sql.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemybranchesschemalibsqlalchemyormmapperpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/schema/lib/sqlalchemy/orm/mapper.py (1427 => 1428)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/schema/lib/sqlalchemy/orm/mapper.py 2006-05-08 18:43:43 UTC (rev 1427) +++ sqlalchemy/branches/schema/lib/sqlalchemy/orm/mapper.py 2006-05-08 19:00:51 UTC (rev 1428) </span><span class="lines">@@ -541,7 +541,6 @@ </span><span class="cx"> """called by a UnitOfWork object to save objects, which involves either an INSERT or </span><span class="cx"> an UPDATE statement for each table used by this mapper, for each element of the </span><span class="cx"> list.""" </span><del>- </del><span class="cx"> #print "SAVE_OBJ MAPPER", self.class_.__name__, objects </span><span class="cx"> connection = uow.transaction.connection(self) </span><span class="cx"> for table in self.tables: </span><span class="lines">@@ -702,7 +701,6 @@ </span><span class="cx"> def delete_obj(self, objects, uow): </span><span class="cx"> """called by a UnitOfWork object to delete objects, which involves a </span><span class="cx"> DELETE statement for each table used by this mapper, for each object in the list.""" </span><del>- </del><span class="cx"> connection = uow.transaction.connection(self) </span><span class="cx"> </span><span class="cx"> for table in util.reversed(self.tables): </span><span class="lines">@@ -826,9 +824,6 @@ </span><span class="cx"> return instance </span><span class="cx"> </span><span class="cx"> def _create_instance(self, session): </span><del>- - #return self.class_(_mapper_nohistory=True, _sa_entity_name=self.entity_name, _sa_session=session) - </del><span class="cx"> obj = self.class_.__new__(self.class_) </span><span class="cx"> obj._entity_name = self.entity_name </span><span class="cx"> </span><span class="lines">@@ -836,8 +831,6 @@ </span><span class="cx"> # in order to save on KeyErrors later on </span><span class="cx"> sessionlib.global_attributes.init_attr(obj) </span><span class="cx"> </span><del>-# TODO: this _attach should not be needed.... -# session._attach(obj) </del><span class="cx"> return obj </span><span class="cx"> </span><span class="cx"> def translate_row(self, tomapper, row): </span></span></pre></div> <a id="sqlalchemybranchesschemalibsqlalchemysqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/schema/lib/sqlalchemy/sql.py (1427 => 1428)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/schema/lib/sqlalchemy/sql.py 2006-05-08 18:43:43 UTC (rev 1427) +++ sqlalchemy/branches/schema/lib/sqlalchemy/sql.py 2006-05-08 19:00:51 UTC (rev 1428) </span><span class="lines">@@ -208,8 +208,7 @@ </span><span class="cx"> text - the text of the SQL statement to be created. use :<param> to specify </span><span class="cx"> bind parameters; they will be compiled to their engine-specific format. </span><span class="cx"> </span><del>- engine - an optional engine to be used for this text query. Alternatively, call the - text() method off the engine directly. </del><ins>+ engine - an optional engine to be used for this text query. </ins><span class="cx"> </span><span class="cx"> bindparams - a list of bindparam() instances which can be used to define the </span><span class="cx"> types and/or initial values for the bind parameters within the textual statement; </span><span class="lines">@@ -246,13 +245,14 @@ </span><span class="cx"> return isinstance(col, ColumnElement) </span><span class="cx"> </span><span class="cx"> class Engine(object): </span><del>- """represents a 'thing that can produce Compiler objects and execute them'.""" </del><ins>+ """represents a 'thing that can produce Compiled objects and execute them'.""" </ins><span class="cx"> def execute_compiled(self, compiled, parameters, echo=None, **kwargs): </span><span class="cx"> raise NotImplementedError() </span><span class="cx"> def compiler(self, statement, parameters, **kwargs): </span><span class="cx"> raise NotImplementedError() </span><span class="cx"> </span><span class="cx"> class AbstractDialect(object): </span><ins>+ """represents the behavior of a particular database. Used by Compiled objects.""" </ins><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> class ClauseParameters(util.OrderedDict): </span><span class="lines">@@ -457,7 +457,7 @@ </span><span class="cx"> def compile(self, engine=None, parameters=None, compiler=None, dialect=None): </span><span class="cx"> """compiles this SQL expression. </span><span class="cx"> </span><del>- Uses the given Compiler, or the given Dialect or Engine to create a Compiler. If no compiler </del><ins>+ Uses the given Compiler, or the given AbstractDialect or Engine to create a Compiler. If no compiler </ins><span class="cx"> arguments are given, tries to use the underlying Engine this ClauseElement is bound </span><span class="cx"> to to create a Compiler, if any. Finally, if there is no bound Engine, uses an ANSIDialect </span><span class="cx"> to create a default Compiler. </span><span class="lines">@@ -598,13 +598,13 @@ </span><span class="cx"> class ColumnElement(Selectable, CompareMixin): </span><span class="cx"> """represents a column element within the list of a Selectable's columns. </span><span class="cx"> A ColumnElement can either be directly associated with a TableClause, or </span><del>- a free-standing textual column with no table, or is a "proxied" column, indicating - it is placed on a Selectable such as an Alias or Select statement and corresponds - to a TableClause attached column. in the case of a CompositeSelect, a ColumnElement - may correspond to several TableClause-attached columns. """ </del><ins>+ a free-standing textual column with no table, or is a "proxy" column, indicating + it is placed on a Selectable such as an Alias or Select statement and ultimately corresponds + to a TableClause-attached column (or in the case of a CompositeSelect, a proxy ColumnElement + may correspond to several TableClause-attached columns).""" </ins><span class="cx"> </span><span class="cx"> primary_key = property(lambda self:getattr(self, '_primary_key', False), doc="primary key flag. indicates if this Column represents part or whole of a primary key.") </span><del>- foreign_key = property(lambda self:getattr(self, '_foreign_key', False), doc="foreign key accessor. points to a ForeignKey object which represents a Foreign Key placed on this column") </del><ins>+ foreign_key = property(lambda self:getattr(self, '_foreign_key', False), doc="foreign key accessor. points to a ForeignKey object which represents a Foreign Key placed on this column's ultimate ancestor.") </ins><span class="cx"> columns = property(lambda self:[self], doc="Columns accessor which just returns self, to provide compatibility with Selectable objects.") </span><span class="cx"> </span><span class="cx"> def _get_orig_set(self): </span><span class="lines">@@ -617,9 +617,10 @@ </span><span class="cx"> if len(s) == 0: </span><span class="cx"> s.add(self) </span><span class="cx"> self.__orig_set = s </span><del>- orig_set = property(_get_orig_set, _set_orig_set,doc="""a Set containing Table-bound, non-proxied ColumnElements for which this ColumnElement is a proxy. In all cases except for a column proxied from a Union (i.e. CompoundSelect), this set will be just one element.""") </del><ins>+ orig_set = property(_get_orig_set, _set_orig_set,doc="""a Set containing TableClause-bound, non-proxied ColumnElements for which this ColumnElement is a proxy. In all cases except for a column proxied from a Union (i.e. CompoundSelect), this set will be just one element.""") </ins><span class="cx"> </span><span class="cx"> def shares_lineage(self, othercolumn): </span><ins>+ """returns True if the given ColumnElement has a common ancestor to this ColumnElement.""" </ins><span class="cx"> for c in self.orig_set: </span><span class="cx"> if c in othercolumn.orig_set: </span><span class="cx"> return True </span><span class="lines">@@ -627,10 +628,8 @@ </span><span class="cx"> return False </span><span class="cx"> def _make_proxy(self, selectable, name=None): </span><span class="cx"> """creates a new ColumnElement representing this ColumnElement as it appears in the select list </span><del>- of an enclosing selectable. The default implementation returns a ColumnClause if a name is given, - else just returns self. This has various mechanics with sql.ColumnClause and sql.Label so that - ColumnClause objects as well as non-column objects like Function and BinaryClause can both appear in the - select list of an enclosing selectable.""" </del><ins>+ of a descending selectable. The default implementation returns a ColumnClause if a name is given, + else just returns self.""" </ins><span class="cx"> if name is not None: </span><span class="cx"> co = ColumnClause(name, selectable) </span><span class="cx"> co.orig_set = self.orig_set </span><span class="lines">@@ -965,7 +964,6 @@ </span><span class="cx"> def __init__(self, left, right, onclause=None, isouter = False): </span><span class="cx"> self.left = left </span><span class="cx"> self.right = right </span><del>- # TODO: if no onclause, do NATURAL JOIN </del><span class="cx"> if onclause is None: </span><span class="cx"> self.onclause = self._match_primaries(left, right) </span><span class="cx"> else: </span><span class="lines">@@ -1085,7 +1083,6 @@ </span><span class="cx"> self.type = sqltypes.to_instance(type) </span><span class="cx"> obj.parens=True </span><span class="cx"> key = property(lambda s: s.name) </span><del>- </del><span class="cx"> _label = property(lambda s: s.name) </span><span class="cx"> orig_set = property(lambda s:s.obj.orig_set) </span><span class="cx"> def accept_visitor(self, visitor): </span><span class="lines">@@ -1220,8 +1217,6 @@ </span><span class="cx"> </span><span class="cx"> class SelectBaseMixin(object): </span><span class="cx"> """base class for Select and CompoundSelects""" </span><del>- def __init__(self): - self.name = None </del><span class="cx"> def order_by(self, *clauses): </span><span class="cx"> if len(clauses) == 1 and clauses[0] is None: </span><span class="cx"> self.order_by_clause = ClauseList() </span><span class="lines">@@ -1259,14 +1254,15 @@ </span><span class="cx"> self.group_by(*kwargs.get('group_by', [None])) </span><span class="cx"> self.order_by(*kwargs.get('order_by', [None])) </span><span class="cx"> self._col_map = {} </span><ins>+ + name = property(lambda s:s.keyword + " statement") + </ins><span class="cx"> def _locate_oid_column(self): </span><span class="cx"> return self.selects[0].oid_column </span><del>- </del><span class="cx"> def _exportable_columns(self): </span><span class="cx"> for s in self.selects: </span><span class="cx"> for c in s.c: </span><span class="cx"> yield c </span><del>- </del><span class="cx"> def _proxy_column(self, column): </span><span class="cx"> if self.use_labels: </span><span class="cx"> col = column._make_proxy(self, name=column._label) </span><span class="lines">@@ -1348,7 +1344,8 @@ </span><span class="cx"> for f in from_obj: </span><span class="cx"> self.append_from(f) </span><span class="cx"> </span><del>- </del><ins>+ name = property(lambda s:"SELECT statement") + </ins><span class="cx"> class CorrelatedVisitor(ClauseVisitor): </span><span class="cx"> """visits a clause, locates any Select clauses, and tells them that they should </span><span class="cx"> correlate their FROM list to that of their parent.""" </span><span class="lines">@@ -1445,14 +1442,6 @@ </span><span class="cx"> return union(self, other, **kwargs) </span><span class="cx"> def union_all(self, other, **kwargs): </span><span class="cx"> return union_all(self, other, **kwargs) </span><del>- -# def scalar(self, *multiparams, **params): - # need to set limit=1, but only in this thread. - # we probably need to make a copy of the select(). this - # is expensive. I think cursor.fetchone(), then discard remaining results - # should be fine with most DBs - # for now use base scalar() method - </del><span class="cx"> def _find_engine(self): </span><span class="cx"> """tries to return a Engine, either explicitly set in this object, or searched </span><span class="cx"> within the from clauses for one""" </span><span class="lines">@@ -1470,7 +1459,6 @@ </span><span class="cx"> </span><span class="cx"> class UpdateBase(ClauseElement): </span><span class="cx"> """forms the base for INSERT, UPDATE, and DELETE statements.""" </span><del>- </del><span class="cx"> def _process_colparams(self, parameters): </span><span class="cx"> """receives the "values" of an INSERT or UPDATE statement and constructs </span><span class="cx"> appropriate ind parameters.""" </span><span class="lines">@@ -1499,10 +1487,8 @@ </span><span class="cx"> except KeyError: </span><span class="cx"> del parameters[key] </span><span class="cx"> return parameters </span><del>- </del><span class="cx"> def _find_engine(self): </span><span class="cx"> return self.table.engine </span><del>- </del><span class="cx"> </span><span class="cx"> class Insert(UpdateBase): </span><span class="cx"> def __init__(self, table, values=None, **params): </span></span></pre> </div> </div> </body> </html> |