Skip to content

add test cases to association proxy for: collection-> (collection of scalar), collection-> (scalar of collection) #2054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqlalchemy-bot opened this issue Feb 13, 2011 · 3 comments
Labels
bug Something isn't working orm
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

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})
@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

additionally:

     def contains(self, obj):
-        return self._comparator.any(**{self.value_attr: obj})
+        # depending on list/scalar on both sides
+        return self._comparator._criterion_exists(getattr(self.target_class, self.value_attr).contains(obj))
+#        return self._comparator.any(**{self.value_attr: obj})

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.

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

2722035

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added bug Something isn't working orm labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 0.7.0 milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working orm
Projects
None yet
Development

No branches or pull requests

1 participant