diff options
| author | Simon Charette <simon.charette@zapier.com> | 2019-09-15 23:25:50 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-09-16 08:53:02 +0200 |
| commit | 574154ef56d432d5b3bb024e7a08880e53755f3d (patch) | |
| tree | e879ceb00164d328a1d02e4d0e4d7fc49bd27978 /tests/postgres_tests/test_hstore.py | |
| parent | 7bd28727ad5f730ddf6085b32c4393adf762df32 (diff) | |
[3.0.x] Fixed #30769 -- Fixed a crash when filtering against a subquery JSON/HStoreField annotation.
This was a regression introduced by 7deeabc7c7526786df6894429ce89a9c4b614086
to address CVE-2019-14234.
Thanks Tim Kleinschmidt for the report and Mariusz for the tests.
Backport of 6c3dfba89215fc56fc27ef61829a6fff88be4abb from master
Diffstat (limited to 'tests/postgres_tests/test_hstore.py')
| -rw-r--r-- | tests/postgres_tests/test_hstore.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/postgres_tests/test_hstore.py b/tests/postgres_tests/test_hstore.py index 502c8447fc..a3fae1ec66 100644 --- a/tests/postgres_tests/test_hstore.py +++ b/tests/postgres_tests/test_hstore.py @@ -2,7 +2,7 @@ import json from django.core import checks, exceptions, serializers from django.db import connection -from django.db.models.expressions import RawSQL +from django.db.models.expressions import OuterRef, RawSQL, Subquery from django.forms import Form from django.test.utils import CaptureQueriesContext, isolate_apps @@ -207,6 +207,12 @@ class TestQuerying(PostgreSQLTestCase): queries[0]['sql'], ) + def test_obj_subquery_lookup(self): + qs = HStoreModel.objects.annotate( + value=Subquery(HStoreModel.objects.filter(pk=OuterRef('pk')).values('field')), + ).filter(value__a='b') + self.assertSequenceEqual(qs, self.objs[:2]) + @isolate_apps('postgres_tests') class TestChecks(PostgreSQLSimpleTestCase): |
