diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-12-08 01:54:08 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-12-08 01:54:08 +0000 |
| commit | 2305e22d6bde2161f5bee25514f0a8444cce8416 (patch) | |
| tree | 54d183a1b92a4473636051554b0c1b28b73e2f98 /lib/sqlalchemy/sql | |
| parent | acb2faedcd1502248e6db46228112133094dd3cf (diff) | |
| download | sqlalchemy-2305e22d6bde2161f5bee25514f0a8444cce8416.tar.gz | |
- backport of r6540
- The "use get" behavior of many-to-one relations, i.e. that a
lazy load will fallback to the possibly cached query.get()
value, now works across join conditions where the two compared
types are not exactly the same class, but share the same
"affinity" - i.e. Integer and SmallInteger. Also allows
combinations of reflected and non-reflected types to work
with 0.5 style type reflection, such as PGText/Text (note 0.6
reflects types as their generic versions). [ticket:1556]
- types now support an "affinity comparison" operation, i.e.
that an Integer/SmallInteger are "compatible", or
a Text/String, PickleType/Binary, etc. Part of
[ticket:1556].
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 83897ef05..cf08ec195 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2003,15 +2003,12 @@ class _BindParamClause(ColumnElement): else: return obj.type - def compare(self, other): - """Compare this ``_BindParamClause`` to the given clause. - - Since ``compare()`` is meant to compare statement syntax, this - method returns True if the two ``_BindParamClauses`` have just - the same type. - - """ - return isinstance(other, _BindParamClause) and other.type.__class__ == self.type.__class__ and self.value == other.value + def compare(self, other, **kw): + """Compare this ``_BindParamClause`` to the given clause.""" + + return isinstance(other, _BindParamClause) and \ + self.type._compare_type_affinity(other.type) and \ + self.value == other.value def __getstate__(self): """execute a deferred value for serialization purposes.""" |
