From bbc5e7c285a160f148eafa0ab442675fe88551ce Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 28 Jan 2007 23:33:53 +0000 Subject: 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. --- lib/sqlalchemy/sql.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql.py') diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 559847261..5f392a61c 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -694,7 +694,12 @@ class ColumnCollection(util.OrderedProperties): if c.shares_lineage(local): l.append(c==local) return and_(*l) - + def contains_column(self, col): + # have to use a Set here, because it will compare the identity + # of the column, not just using "==" for comparison which will always return a + # "True" value (i.e. a BinaryClause...) + return col in util.Set(self) + class FromClause(Selectable): """represents an element that can be used within the FROM clause of a SELECT statement.""" def __init__(self, name=None): @@ -1400,6 +1405,7 @@ class CompoundSelect(_SelectBaseMixin, FromClause): for c in s.c: yield c def _proxy_column(self, column): + print "PROXYING COLUMN", type(column), column if self.use_labels: col = column._make_proxy(self, name=column._label) else: -- cgit v1.2.1