From 73f734bf80166c7dfce4892941752d7569a17524 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 6 Feb 2012 12:20:15 -0500 Subject: initial annotations approach to join conditions. all tests pass, plus additional tests in #1401 pass. would now like to reorganize RelationshipProperty more around the annotations concept. --- lib/sqlalchemy/sql/expression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql/expression.py') diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index b11e5ad42..30e19bc68 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2184,7 +2184,7 @@ class ColumnElement(ClauseElement, _CompareMixin): for oth in to_compare: if use_proxies and self.shares_lineage(oth): return True - elif oth is self: + elif hash(oth) == hash(self): return True else: return False -- cgit v1.2.1 From d1414ad20524c421aa78272c03dce5f839a0aab6 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 8 Feb 2012 10:14:36 -0500 Subject: simplify remote annotation significantly, and also catch the actual remote columns more accurately. --- lib/sqlalchemy/sql/expression.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/sqlalchemy/sql/expression.py') diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 30e19bc68..72099a5f5 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -3384,6 +3384,10 @@ class _BinaryExpression(ColumnElement): except: raise TypeError("Boolean value of this clause is not defined") + @property + def is_comparison(self): + return operators.is_comparison(self.operator) + @property def _from_objects(self): return self.left._from_objects + self.right._from_objects -- cgit v1.2.1 From bc45fa350a02da5f24d866078abed471cd98f15b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 9 Feb 2012 21:16:53 -0500 Subject: - got m2m, local_remote_pairs, etc. working - using new traversal that returns the product of both sides of a binary, starting to work with (a+b) == (c+d) types of joins. primaryjoins on functions working - annotations working, including reversing local/remote when doing backref --- lib/sqlalchemy/sql/expression.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'lib/sqlalchemy/sql/expression.py') diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 72099a5f5..ebf4de9a2 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1576,18 +1576,30 @@ class ClauseElement(Visitable): return id(self) def _annotate(self, values): - """return a copy of this ClauseElement with the given annotations - dictionary. + """return a copy of this ClauseElement with annotations + updated by the given dictionary. """ return sqlutil.Annotated(self, values) - def _deannotate(self): - """return a copy of this ClauseElement with an empty annotations - dictionary. + def _with_annotations(self, values): + """return a copy of this ClauseElement with annotations + replaced by the given dictionary. """ - return self._clone() + return sqlutil.Annotated(self, values) + + def _deannotate(self, values=None): + """return a copy of this :class:`.ClauseElement` with annotations + removed. + + :param values: optional tuple of individual values + to remove. + + """ + # since we have no annotations we return + # self + return self def unique_params(self, *optionaldict, **kwargs): """Return a copy with :func:`bindparam()` elments replaced. -- cgit v1.2.1 From d934ea23e24880a5c784c9e5edf9ead5bc965a83 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 11 Feb 2012 20:33:56 -0500 Subject: - figured out again why deannotate must clone() - got everything working. just need to update error strings --- lib/sqlalchemy/sql/expression.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/sql/expression.py') diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index ebf4de9a2..573ace47f 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1589,7 +1589,7 @@ class ClauseElement(Visitable): """ return sqlutil.Annotated(self, values) - def _deannotate(self, values=None): + def _deannotate(self, values=None, clone=False): """return a copy of this :class:`.ClauseElement` with annotations removed. @@ -1597,9 +1597,14 @@ class ClauseElement(Visitable): to remove. """ - # since we have no annotations we return - # self - return self + if clone: + # clone is used when we are also copying + # the expression for a deep deannotation + return self._clone() + else: + # if no clone, since we have no annotations we return + # self + return self def unique_params(self, *optionaldict, **kwargs): """Return a copy with :func:`bindparam()` elments replaced. -- cgit v1.2.1