{{{
NullableIntegerArrayModel.objects.filter(field__in=[models.F('field')]),
}}}
i.e., filtering an ArrayField using `__in` with expressions that evaluate
to other ArrayField references.
However, the following fails:
{{{
NullableIntegerArrayModel.objects.filter(field__in=[[models.F('id')]]),
}}}
i.e., building a new array that contains scalar expressions.
There are some tests, marked with expectedFailure, in
`postgres_tests.test_array`: `test_in_including_F_object` and
`test_contained_by_including_F_object`, that demonstrate this problem.
--
Ticket URL: <https://code.djangoproject.com/ticket/27095>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Database layer (models, ORM) => contrib.postgres
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:1>
* owner: nobody => PREM1980
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:2>
Comment (by PREM1980):
Im unable to locate the postgres_tests.test_array:
test_in_including_F_object and test_contained_by_including_F_object in the
master branch.
Can you please point me to the correct location?
It would be great if you can build an example, so we both are on the same
page.
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:3>
Comment (by timgraham):
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:4>
* owner: PREM1980 =>
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:5>
* owner: (none) => Hannes Ljungberg
* status: new => assigned
* has_patch: 0 => 1
Comment:
I've created a PR (https://github.com/django/django/pull/13680) to fix the
issue of allowing expressions on ArrayField lookups where the right-hand
side is a list. Note that this PR does not fix the issue of expressions in
nested lists, it should in my opinion be tracked as a separate ticket. I'm
not really familiar with the process of splitting up tickets, would it
make sense to create a new ticket for the nested expressions in the case
of this PR being merged?
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:7>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"33403bf80f635577a18426bc99c8a65e31fd8dfa" 33403bf8]:
{{{
#!CommitTicketReference repository=""
revision="33403bf80f635577a18426bc99c8a65e31fd8dfa"
Refs #27095 -- Allowed (non-nested) arrays containing expressions for
ArrayField lookups.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:8>
* has_patch: 1 => 0
* stage: Ready for checkin => Accepted
Comment:
Nested arrays still don't work with expressions.
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:9>
Comment (by GitHub <noreply@…>):
In [changeset:"d746f28949c009251a8741ba03d156964050717f" d746f289]:
{{{
#!CommitTicketReference repository=""
revision="d746f28949c009251a8741ba03d156964050717f"
Refs #27095 -- Fixed test_contained_by_including_F_object when run in
reverse.
Tests should not rely on auto PKs.
Test regression in 33403bf80f635577a18426bc99c8a65e31fd8dfa.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:10>
* owner: Hannes Ljungberg => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/27095#comment:11>