Querying in a sub query seems not exclude deleted items
See original GitHub issueAs you see below, items are not excluded…
358278 is soft deleted and not appear in a normal query
In [11]: WidgetItem.objects.values_list('widget').filter(id=358278)
Out[11]: <SafeDeleteQueryset []>
But not in a more complex query like this:
In [8]: widget_items = WidgetItem.objects.values_list('widget').filter(id=358278)
In [9]: Widget.objects.filter(id__in=widget_items).distinct()
Out[9]: <SafeDeleteQueryset [<Widget: 358278>]>
Any recommandations ?
And when printing query, deleted field are not excluded too:
In [8]: print(WidgetItem.objects.filter(id=358278).values_list('widget').query)
SELECT `nfb_widgets_widgetitem`.`widget_id` FROM `nfb_widgets_widgetitem` WHERE `nfb_widgets_widgetitem`.`id` = 358278 ORDER BY `nfb_widgets_widgetitem`.`order` ASC
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Consider using [NOT] EXISTS instead of [NOT] IN with a ...
Phil Factor explains why you should prefer use of [NOT] EXISTS over [NOT] IN, when comparing data sets using a subquery.
Read more >SQL Exclude results from join or subquery where column ...
Ok, I'm working with an existing database (cannot edit the tables, columns, etc.) I am asked to create a report with the data...
Read more >13.2.15.6 Subqueries with EXISTS or NOT EXISTS
If a subquery returns any rows at all, EXISTS subquery is TRUE , and NOT EXISTS subquery is FALSE . For example: SELECT...
Read more >[Solved] Exclude records using a subquery in SQL SERVER
I have to exclude some records( i can't delete) i am trying to create a view. Tried with sub queries but not worked...
Read more >Syntax and Examples of SQL EXCLUDE - eduCBA
The basic syntax for writing exclude queries in SQL are as follows: ... Exclude rows using NOT IN operator with subqueries on the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is fixed in master, I’ll have to migrate the test runners to github actions before releasing it.
released in 0.5.7