Re: Please add exists subquery to queryset api

2014-11-11 Thread George Ma
Yes, that's the query i'd like to have. On Monday, November 10, 2014 10:38:41 PM UTC-7, Curtis Maloney wrote: > > Can you provide the "natural" SQL version you'd rather see generated? > > Something like: > > SELECT ... FROM myapp_a WHERE NOT EXISTS (SELECT 1 FROM myapp_b T1 WHERE > T1.a_id = myap

Re: Please add exists subquery to queryset api

2014-11-10 Thread Curtis Maloney
Can you provide the "natural" SQL version you'd rather see generated? Something like: SELECT ... FROM myapp_a WHERE NOT EXISTS (SELECT 1 FROM myapp_b T1 WHERE T1.a_id = myapp_a.id AND T1.criteria = True) perhaps? On 11 November 2014 16:18, George Ma wrote: > Yes, the actual sql is very close

Re: Please add exists subquery to queryset api

2014-11-10 Thread George Ma
Yes, the actual sql is very close to this one. But I just feel this approach is like a hack. Because I always have to reverse the logic first and then reverse again. Not as natural as exists subquery. On Monday, November 10, 2014 5:53:47 PM UTC-7, Curtis Maloney wrote: > > If you want to know th

Re: Please add exists subquery to queryset api

2014-11-10 Thread Curtis Maloney
If you want to know the SQL generated for any particular queryset, you can just: print str(qs.query) On 11 November 2014 11:39, George Ma wrote: > For simplicity, let's assume we have a model A and model B. > > class A(models.Model): > name = models.CharField(max_length=200) > > class B

Re: Please add exists subquery to queryset api

2014-11-10 Thread George Ma
For simplicity, let's assume we have a model A and model B. class A(models.Model): name = models.CharField(max_length=200) class B(models.Model): a = models.ForeignKey(A) criteria = models.BooleanField(default = False) Let's say there's a requirement to find A that doesn't have a B w

Re: Please add exists subquery to queryset api

2014-11-09 Thread Shai Berger
Hello George, On Sunday 09 November 2014 05:33:36 George Ma wrote: > I've encountered quite a few cases where I need to write complicated > queries where a exists subquery makes more sense and has better > performance. So far, there's no exists subquey support in queryset api. > Please add it. I

Please add exists subquery to queryset api

2014-11-08 Thread George Ma
I've encountered quite a few cases where I need to write complicated queries where a exists subquery makes more sense and has better performance. So far, there's no exists subquey support in queryset api. Please add it. -- You received this message because you are subscribed to the Google Grou