add test cases to association proxy for: collection-> (collection of scalar), collection-> (scalar of collection)
Issue #2054
resolved
two tests expect an error condition to occur which fails here, but need this for the variety of scenarios:
diff -r 15520d5d81b9c45f6735df82ce0d593e93ad2bdf lib/sqlalchemy/ext/associationproxy.py
--- a/lib/sqlalchemy/ext/associationproxy.py Sat Feb 12 22:29:36 2011 -0500
+++ b/lib/sqlalchemy/ext/associationproxy.py Sun Feb 13 14:58:25 2011 -0500
@@ -277,11 +277,15 @@
def _comparator(self):
return self._get_property().comparator
+ def _criterion_exists(self, type_, criterion=None, **kwargs):
+ return self._comparator._criterion_exists(getattr(self.target_class, self.value_attr).\
+ _criterion_exists(criterion, **kwargs))
+
def any(self, criterion=None, **kwargs):
- return self._comparator.any(getattr(self.target_class, self.value_attr).has(criterion, **kwargs))
+ return self._criterion_exists('any', criterion=criterion, **kwargs)
def has(self, criterion=None, **kwargs):
- return self._comparator.has(getattr(self.target_class, self.value_attr).has(criterion, **kwargs))
+ return self._criterion_exists('has',criterion=criterion, **kwargs)
def contains(self, obj):
return self._comparator.any(**{self.value_attr: obj})
Comments (3)
-
reporter -
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.7.0 (automated comment)
- Log in to comment
additionally:
the association proxy will need accessors that tell it what list/scalar type is both the "target" and "value", and all of these comparators must switch off of that.