diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-28 23:33:53 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-28 23:33:53 +0000 |
commit | bbc5e7c285a160f148eafa0ab442675fe88551ce (patch) | |
tree | 71f407e9de4c29ac427d01acc7730ac3dd714a80 /lib/sqlalchemy/ext/selectresults.py | |
parent | 7a1a746d7abaebb1e1712224a8ebbf037cc94435 (diff) | |
download | sqlalchemy-bbc5e7c285a160f148eafa0ab442675fe88551ce.tar.gz |
merged the polymorphic relationship refactoring branch in. i want to go further on that branch and introduce the foreign_keys argument, and further centralize the "intelligence" about the joins and selectables into PropertyLoader so that lazyloader/sync can be simplified, but the current branch goes pretty far.
- relations keep track of "polymorphic_primaryjoin", "polymorphic_secondaryjoin" which it derives from the plain primaryjoin/secondaryjoin.
- lazy/eagerloaders work from those polymorphic join objects.
- the join exported by PropertyLoader to Query/SelectResults is the polymorphic join, so that join_to/etc work properly.
- Query builds itself against the base Mapper again, not the "polymorphic" mapper. uses the "polymorphic" version
only as appropriate. this helps join_by/join_to/etc to work with polymorphic mappers.
- Query will also adapt incoming WHERE criterion to the polymorphic mapper, i.e. the "people" table becomes the "person_join" automatically.
- quoting has been modified since labels made out of non-case-sensitive columns could themselves require quoting..so case_sensitive defaults to True if not otherwise specified (used to be based on the identifier itself).
- the test harness gets an ORMTest base class and a bunch of the ORM unit tests are using it now, decreases a lot of redundancy.
Diffstat (limited to 'lib/sqlalchemy/ext/selectresults.py')
-rw-r--r-- | lib/sqlalchemy/ext/selectresults.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/ext/selectresults.py b/lib/sqlalchemy/ext/selectresults.py index c2ad40917..153b0c2b9 100644 --- a/lib/sqlalchemy/ext/selectresults.py +++ b/lib/sqlalchemy/ext/selectresults.py @@ -71,7 +71,10 @@ class SelectResults(object): def select(self, clause): return self.filter(clause) - + + def select_by(self, *args, **kwargs): + return self.filter(self._query._join_by(args, kwargs, start=self._joinpoint[1])) + def order_by(self, order_by): """apply an ORDER BY to the query.""" new = self.clone() @@ -131,9 +134,12 @@ class SelectResults(object): for key in keys: prop = mapper.props[key] if outerjoin: - clause = clause.outerjoin(prop.mapper.mapped_table, prop.get_join()) + clause = clause.outerjoin(prop.select_table, prop.get_join()) else: - clause = clause.join(prop.mapper.mapped_table, prop.get_join()) + clause = clause.join(prop.select_table, prop.get_join()) + print "SELECT_TABLE", prop.select_table + print "JOIN", prop.get_join() + print "CLAUSE", str(clause), "DONE CLAUSE" mapper = prop.mapper return (clause, mapper) |