summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/mods
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-04-06 21:12:00 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-04-06 21:12:00 +0000
commit5bda70e770489a09a848d5ac3bfbee0aabd805ab (patch)
tree081c39dfb9a8486f78f923de3e3843e5d10eb634 /lib/sqlalchemy/mods
parentc0e5bb085b052e016d75ecf8e0a24584a2de730a (diff)
downloadsqlalchemy-5bda70e770489a09a848d5ac3bfbee0aabd805ab.tar.gz
mapper's querying facilities migrated to new query.Query() object, which can receive session-specific context via the mapper.using() statement. reuslting object instances will be bound to this session, but query execution still handled by the SQLEngines implicit in the mapper's Table objects.
session now propigates to the unitofwork UOWTransaction object, as well as mapper's save_obj/delete_obj via the UOWTransaction it receives. UOWTransaction explicitly calls the Session for the engine corresponding to each Mapper in the flush operation, although the Session does not yet affect the choice of engines used, and mapper save/delete is still using the Table's implicit SQLEngine. changed internal unitofwork commit() method to be called flush(). removed all references to 'engine' from mapper module, including adding insert/update specific SQLEngine methods such as last_inserted_ids, last_inserted_params, etc. to the returned ResultProxy so that Mapper need not know which SQLEngine was used for the execute. changes to unit tests, SelectResults to support the new Query object.
Diffstat (limited to 'lib/sqlalchemy/mods')
-rw-r--r--lib/sqlalchemy/mods/selectresults.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/sqlalchemy/mods/selectresults.py b/lib/sqlalchemy/mods/selectresults.py
index b4f16c41c..5528c7bf6 100644
--- a/lib/sqlalchemy/mods/selectresults.py
+++ b/lib/sqlalchemy/mods/selectresults.py
@@ -6,25 +6,25 @@ def install_plugin():
mapping.global_extensions.append(SelectResultsExt)
class SelectResultsExt(mapping.MapperExtension):
- def select_by(self, mapper, *args, **params):
- return SelectResults(mapper, mapper._by_clause(*args, **params))
- def select(self, mapper, arg=None, **kwargs):
+ def select_by(self, query, *args, **params):
+ return SelectResults(query, query._by_clause(*args, **params))
+ def select(self, query, arg=None, **kwargs):
if arg is not None and isinstance(arg, sql.Selectable):
return mapping.EXT_PASS
else:
- return SelectResults(mapper, arg, ops=kwargs)
+ return SelectResults(query, arg, ops=kwargs)
MapperExtension = SelectResultsExt
class SelectResults(object):
- def __init__(self, mapper, clause=None, ops={}):
- self._mapper = mapper
+ def __init__(self, query, clause=None, ops={}):
+ self._query = query
self._clause = clause
self._ops = {}
self._ops.update(ops)
def count(self):
- return self._mapper.count(self._clause)
+ return self._query.count(self._clause)
def min(self, col):
return sql.select([sql.func.min(col)], self._clause, **self._ops).scalar()
@@ -39,7 +39,7 @@ class SelectResults(object):
return sql.select([sql.func.avg(col)], self._clause, **self._ops).scalar()
def clone(self):
- return SelectResults(self._mapper, self._clause, self._ops.copy())
+ return SelectResults(self._query, self._clause, self._ops.copy())
def filter(self, clause):
new = self.clone()
@@ -83,4 +83,4 @@ class SelectResults(object):
return list(self[item:item+1])[0]
def __iter__(self):
- return iter(self._mapper.select_whereclause(self._clause, **self._ops))
+ return iter(self._query.select_whereclause(self._clause, **self._ops))