Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2023-07-03 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
-+-
 Reporter:  Przemek  |Owner:  bcail
 Type:  New feature  |   Status:  closed
Component:  contrib.postgres |  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak):

 Martin, thanks for the report, however it works for me with an empty
 subquery, e.g.
 {{{#!diff
 diff --git a/tests/postgres_tests/test_array.py
 b/tests/postgres_tests/test_array.py
 index f7615c974e..9a3966a821 100644
 --- a/tests/postgres_tests/test_array.py
 +++ b/tests/postgres_tests/test_array.py
 @@ -423,6 +423,21 @@ class TestQuerying(PostgreSQLTestCase):
  self.objs[:3],
  )

 +def test_overlap_values_empty(self):
 +qs = NullableIntegerArrayModel.objects.filter(order__lt=0)
 +self.assertSequenceEqual(
 +NullableIntegerArrayModel.objects.filter(
 +field__overlap=qs.values_list("field"),
 +),
 +[],
 +)
 +self.assertSequenceEqual(
 +NullableIntegerArrayModel.objects.filter(
 +
 field__overlap=NullableIntegerArrayModel.objects.none().values("field"),
 +),
 +[],
 +)
 +
  def test_lookups_autofield_array(self):
  qs = (
  NullableIntegerArrayModel.objects.filter(

 }}}

 If you believe it's an issue in Django, then please create a **new
 ticket** in Trac and follow our
 [https://docs.djangoproject.com/en/dev/internals/contributing/bugs-and-
 features/#reporting-bugs bug reporting guidelines]. A sample project that
 reproduces your issue would be very helpful.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701891b5bc20a-45502c05-c4a1-4889-8be2-67024cf74baf-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2023-07-03 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
-+-
 Reporter:  Przemek  |Owner:  bcail
 Type:  New feature  |   Status:  closed
Component:  contrib.postgres |  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Martin Lehoux):

 Hi! I feel late to the battle, because I just upgraded from Django 4.1 to
 Django 4.2, and I have an issue with this improvement.

 I'll try to give a short example.

 {{{
 class Post(Model):
 name = CharField()
 tags = ArrayField(CharField())

 class User(Model):
 post = ForeignKey(Post)

 current_post = Post.objects.filter(pk=OuterRef("post"))
 matching_posts =
 Post.objects.filter(Q(tags__overlap=current_post.values("tags"))
 user = User.objects.annotate(matching_posts=matching_posts.values("name"))
 }}}

 This worked well before because we rely on current_post.values to return a
 single value.
 But now, this current_post.values is wrapped with a call to Array, and I
 get `cannot accumulate empty arrays` error if the post has no tags.

 Before:
 {{{
 WHERE tags && (SELECT tags FROM posts WHERE id = 123)
 }}}

 Now:
 {{{
 WHERE tags && ARRAY(SELECT tags FROM posts WHERE id = 123)
 }}}

 Maybe there is another (and better) way to achieve this, but it seems that
 it has broken my use of .values in the right side.

 If this is not clear enough, please tell me and I will setup a more
 thorough example (I haven't tested this one, it's extracted from my work
 codebase).

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701891b2d6bdb-d8380b8c-dffb-4214-aaee-c45d78ffdcde-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2022-11-17 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
-+-
 Reporter:  Przemek  |Owner:  bcail
 Type:  New feature  |   Status:  closed
Component:  contrib.postgres |  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"fbde929b19754f19cba1d14e86f4c59f4b0a633c" fbde929]:
 {{{
 #!CommitTicketReference repository=""
 revision="fbde929b19754f19cba1d14e86f4c59f4b0a633c"
 Fixed #26056 -- Added QuerySet.values()/values_list() support for
 ArrayField's __overlap lookup.

 Thanks Mads Jensen and kosz85 and the initial patch.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701848933bf84-3e0f5d8d-f64b-424a-91f9-658a9aedb595-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2022-11-17 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
-+-
 Reporter:  Przemek  |Owner:  bcail
 Type:  New feature  |   Status:  assigned
Component:  contrib.postgres |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  1 => 0
 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184891f8a53-814775b2-2b2f-4aa1-9def-064a3c8fd90b-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2022-11-17 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  bcail
 Type:  New feature   |   Status:  assigned
Component:  contrib.postgres  |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018485a2a804-d726b8f8-1fe5-49e6-b830-5abda2a6432e-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2022-11-17 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  bcail
 Type:  New feature   |   Status:  assigned
Component:  contrib.postgres  |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * owner:  (none) => bcail
 * status:  new => assigned


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701848589b183-489eacd7-600a-491b-9c00-7badef298a23-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2022-11-16 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by bcail):

 * needs_better_patch:  1 => 0


Comment:

 New PR: https://github.com/django/django/pull/16303

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184824a4de5-9f6eb61f-afc2-4f65-891b-a9c1f28b5dfb-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2022-10-25 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Simon Charette):

 bcail, yep that seems about right!

 Could you submit a PR that does that with a commit message that mentions
 Mads Jensen and kosz85 efforts and add a mention to the release notes for
 4.2?

 Once done unchecking ''patch needs improvement'' here should get it under
 reviewers' eyes.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018410861d1e-59adc7be-8eba-4dda-8819-bf988527d697-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2022-10-25 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by bcail):

 @Simon, were you thinking something like this (modified from the PR)?
 {{{
 diff --git a/django/contrib/postgres/lookups.py
 b/django/contrib/postgres/lookups.py
 index f2f88ebc0a..efb2fb6b12 100644
 --- a/django/contrib/postgres/lookups.py
 +++ b/django/contrib/postgres/lookups.py
 @@ -1,4 +1,5 @@
  from django.db.models import Transform
 +from django.db.models.sql.compiler import Query
  from django.db.models.lookups import PostgresOperatorLookup

  from .search import SearchVector, SearchVectorExact, SearchVectorField
 @@ -18,6 +19,13 @@ class Overlap(PostgresOperatorLookup):
  lookup_name = "overlap"
  postgres_operator = "&&"

 +def process_rhs(self, qn, connection):
 +if isinstance(self.rhs, Query):
 +from .expressions import ArraySubquery
 +self.rhs = ArraySubquery(self.rhs)
 +rhs, params = super().process_rhs(qn, connection)
 +return rhs, params
 +

  class HasKey(PostgresOperatorLookup):
  lookup_name = "has_key"
 diff --git a/tests/postgres_tests/test_array.py
 b/tests/postgres_tests/test_array.py
 index c23ed9fe0c..9dd56630f9 100644
 --- a/tests/postgres_tests/test_array.py
 +++ b/tests/postgres_tests/test_array.py
 @@ -384,6 +384,19 @@ class TestQuerying(PostgreSQLTestCase):
  [obj_1, obj_2],
  )

 +def test_overlap_values_array_field(self):
 +# issue 26056
 +post1 = CharArrayModel(field=['django'])
 +post2 = CharArrayModel(field=['thoughts'])
 +post3 = CharArrayModel(field=['tutorial'])
 +CharArrayModel.objects.bulk_create([post1, post2, post3])
 +qs =
 
CharArrayModel.objects.filter(field__overlap=CharArrayModel.objects.values_list('field',
 flat=True))
 +self.assertSequenceEqual(qs.values_list('field', flat=True), [
 +(['django']),
 +(['thoughts']),
 +(['tutorial']),
 +])
 +
  def test_lookups_autofield_array(self):
  qs = (
  NullableIntegerArrayModel.objects.filter(
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184102d1397-3a44cfd4-6310-4c26-8300-abb1067bdbee-00%40eu-central-1.amazonses.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2021-07-06 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Simon Charette):

 Now that #32776 landed in the main branch this issue should be
 straightforward to fix adjusting the `Overlap.lookup`
 
[https://github.com/django/django/blob/6a5ef557f80a8eb6a758ebe99c8bb477ca47459e/django/contrib/postgres/lookups.py#L17-L19
 lookup] by wrapping a `QuerySet` instance into an `ArraySubquery`.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.289bb69906ab44a28a4439eda37a589a%40djangoproject.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2021-07-06 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Peter Law):

 For anyone who ends up searching for this, the failure (as of 2.2 and
 possibly earlier) is a `ProgrammingError` from the database rather than
 the `TypeError` mentioned above.

 The workaround mentioned in
 https://github.com/django/django/pull/7838#issuecomment-337223376
 continues to work:
 {{{#!python
 A.objects.filter(
 array_field__overlap=models.Func(
 B.objects.values('pk'),
 function='array',
 ),
 )
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c2ce7c26b3fbfd14f580edab5bad8f85%40djangoproject.com.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2017-10-17 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  master
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by kosz85):

 I posted solution here:
 https://github.com/django/django/pull/7838#issuecomment-337223376
 It's Array with Subquery, just pure subquery isn't enough.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.790db99b646dbbf0b2e376d6b1e8ae35%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2017-02-20 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  master
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Alex3917):

 Does the new Subquery functionality is Django 1.11 allow for a similar
 result? E.g.:

 {{{
 qs_b = B.objects.filter(foo)
 A.objects.filter(array_field__overlap=Subquery(qs_b.values_list('id',
 flat=True)))
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.f798c2ab7fe57ebe305333008c3f2f12%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2017-02-06 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  master
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mads Jensen):

 * needs_docs:  1 => 0


Comment:

 It has been reworked but I suppose other lookups in
 `django.contrib.postgres` will want a similar functionality.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.38eff82be66134ad010c0587d9e73d6f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2017-01-13 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  master
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  1
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Simon Charette):

 * needs_better_patch:  0 => 1


--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.5932d08d36e94a295295fe142fe0b954%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2017-01-12 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  Przemek   |Owner:  (none)
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  master
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  1
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mads Jensen):

 * needs_docs:  0 => 1
 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/7838 PR] it follows the suggestion
 to wrap a query inside `array`. Needs documentation is marked, since the
 release notes need to be updated, and probably also a note in the
 documentation itself.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.4b920eb1988b9a8d7840aedb57c3ca21%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2016-01-08 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  CGenie|Owner:
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  master
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Description changed by timgraham:

Old description:

> Basically queries of type:
>
> {{{#!python
> A.objects.filter(array_field__overlap=B.objects.filter(foo))
> }}}
>
> fail at Python level:
>
> {{{
> Traceback (most recent call last):
>   File "failing.py", line 9, in 
> UserList.objects.filter(users__overlap=User.objects.all().values_list('id',
> flat=True)).count()
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/query.py", line 318, in
> count
> return self.query.get_count(using=self.db)
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/sql/query.py", line 466,
> in get_count
> number = obj.get_aggregation(using, ['__count'])['__count']
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/sql/query.py", line 447,
> in get_aggregation
> result = compiler.execute_sql(SINGLE)
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line
> 829, in execute_sql
> sql, params = self.as_sql()
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line
> 387, in as_sql
> where, w_params = self.compile(self.query.where)
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line
> 357, in compile
> sql, params = node.as_sql(self, self.connection)
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/sql/where.py", line 104,
> in as_sql
> sql, params = compiler.compile(child)
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line
> 357, in compile
> sql, params = node.as_sql(self, self.connection)
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/contrib/postgres/fields/array.py",
> line 183, in as_sql
> sql, params = super(ArrayOverlap, self).as_sql(qn, connection)
>   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
> packages/Django-1.8.5-py2.7.egg/django/contrib/postgres/lookups.py", line
> 8, in as_sql
> params = lhs_params + rhs_params
> TypeError: can only concatenate list (not "tuple") to list
> }}}
>
> Toy project to reproduce this behavior can be found here:
> https://github.com/CGenie/django_array_join_fail
>
> This fails in 1.8 as well as in 1.9.

New description:

 Basically queries of type:

 {{{#!python
 A.objects.filter(array_field__overlap=B.objects.filter(foo).values_list('id',
 flat=True))
 }}}

 fail at Python level:

 {{{
 Traceback (most recent call last):
   File "failing.py", line 9, in 
 UserList.objects.filter(users__overlap=User.objects.all().values_list('id',
 flat=True)).count()
   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
 packages/Django-1.8.5-py2.7.egg/django/db/models/query.py", line 318, in
 count
 return self.query.get_count(using=self.db)
   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
 packages/Django-1.8.5-py2.7.egg/django/db/models/sql/query.py", line 466,
 in get_count
 number = obj.get_aggregation(using, ['__count'])['__count']
   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
 packages/Django-1.8.5-py2.7.egg/django/db/models/sql/query.py", line 447,
 in get_aggregation
 result = compiler.execute_sql(SINGLE)
   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
 packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line
 829, in execute_sql
 sql, params = self.as_sql()
   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
 packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line
 387, in as_sql
 where, w_params = self.compile(self.query.where)
   File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-
 packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line
 357, in compile
 sql, params = node.as_sql(self, self.connection)
   File 

Re: [Django] #26056: ArrayField does not work with ValueListQuerySet

2016-01-08 Thread Django
#26056: ArrayField does not work with ValueListQuerySet
--+
 Reporter:  CGenie|Owner:
 Type:  New feature   |   Status:  new
Component:  contrib.postgres  |  Version:  master
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by charettes):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * version:  1.9 => master
 * needs_docs:   => 0
 * type:  Bug => New feature
 * stage:  Unreviewed => Accepted


Comment:

 Accepting as a new feature by assuming you meant
 `B.objects.filter(foo).values('pk')` in your reported example.

 The implementation could simply use the PostgreSQL `array()` function to
 wrap the queryset.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.1bcf253f740160d6cc428648d0c1dff6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.