Skip to content
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

Allow Distinct Queries #49

Open
gurelkaynak opened this issue Jan 6, 2014 · 2 comments
Open

Allow Distinct Queries #49

gurelkaynak opened this issue Jan 6, 2014 · 2 comments

Comments

@gurelkaynak
Copy link

I'm using django-nonrel 1.6-beta with djangotoolbox. Some of my admin pages needed to use DISTINCT but djangotoolbox prevented that in /db/basecompiler.py line 451:

diff --git a/djangotoolbox/db/basecompiler.py b/djangotoolbox/db/basecompiler.py
index 71d9ec8..47fa95b 100644
--- a/djangotoolbox/db/basecompiler.py
+++ b/djangotoolbox/db/basecompiler.py
@@ -451,7 +451,7 @@ class NonrelCompiler(SQLCompiler):
             raise EmptyResultSet()
         if (len([a for a in self.query.alias_map if
                  self.query.alias_refcount[a]]) > 1 or
-            self.query.distinct or self.query.extra or self.query.having):
+            self.query.extra or self.query.having):
             raise DatabaseError("This query is not supported by the database.")

     def get_count(self, check_exists=False):

Can somebody explain why using distinct raises this DatabaseError?

I'll also try to push this to a branch.

Thank you.

@gurelkaynak
Copy link
Author

I realized that distinct queries are not supported by django_mongo_engine...

@gurelkaynak
Copy link
Author

Actually they seem to be supported like this distinct('foo'). When called without arguments it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant